宝塔计划任务实现定时备份Openclaw/Workspace到Github

在服务器执行

https://github.com/用户名/库名/settings/keys

添加一个Deploy keys

把

bash 复制代码
ssh-keygen -t ed25519 -C "openclaw"
cat ~/.ssh/id_ed25519.pub

输出的内容复制到

Deploy keys

服务器执行:

bash 复制代码
ssh -T git@github.com

在~/.openclaw/Workspace执行

bash 复制代码
git remote add origin git@github.com:用户名/库名.git

宝塔添加计划任务(上传Openclaw-Workspace):/

bash 复制代码
#!/bin/bash

# 1. 进入目录(建议写全路径)
WORKDIR="/root/.openclaw/workspace"
cd $WORKDIR || exit

# 确保当前分支叫 main
git checkout -B main

# 3. 添加并提交
git add .

# 检查是否有内容需要提交(避免产生空的 commit 报错)
if ! git diff-index --quiet HEAD --; then
    git commit -m "Auto-update: $(date '+%Y-%m-%d %H:%M:%S')"
    
    # 4. 强制推送覆盖远程
    # -f 会强制让 GitHub 仓库和本地保持完全一致
    git push -u origin main -f
    echo "Successfully pushed to GitHub."
else
    echo "No changes detected. Skipping push."
fi
相关推荐
wflynn10 小时前
GitHub 日榜趋势速报 | 2026-11-18
开源·github
Hvitur11 小时前
Git - 多分支合并
git·github
laoyeye83115 小时前
手写 vLLM 分页 KV Cache(三):引用计数、写时复制(CoW)与前缀缓存
人工智能·github
一条Go18 小时前
边缘 Agent:为什么是它连出来,而不是平台连进去
后端·架构·github
一条Go18 小时前
开源新生代雷达 · 第 15 期
github
OpenTiny社区19 小时前
我用Vue 100%复制DeepSeek开源的网页App,代码更少,功能还更多!
前端·vue.js·github
Bigger20 小时前
我扒了 GitHub Trending 前 20,8 个在做同一件事:给 Coding Agent 造基础设施
开源·github·ai编程
徐小夕21 小时前
MedDoc AI:把临床书写、协作、质控、知识问答装进一个工作台
前端·vue.js·github
cong_21 小时前
🐟 我把摸鱼岛重写了!现在群聊还能装进一张表格
前端·后端·github
wflynn1 天前
GitHub 今日推荐|rust-anything:录制真实输入输出,渐进式重写热点函数到 Rust
rust·开源·github·cli·claude-code·agent-skills