宝塔计划任务实现定时备份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
相关推荐
峰向AI1 小时前
Kage: 一个 244KB 文件,做出百万级视觉效果
github
m4Rk_4 小时前
【论文阅读】Agent 记忆机制(74):CompassMem——从相似度检索走向事件图上的记忆导航
论文阅读·人工智能·学习·开源·github
wflynn5 小时前
GitHub 日榜趋势速报 | 2026-09-18
开源·github
粥里有勺糖8 小时前
视野修炼第133期 | Native 回春了?
前端·github·agent
Mr.朱鹏11 小时前
Git 仓库同时推送到 Gitee 与 GitHub 配置指南
git·gitee·开源·github
All for pursuit.13 小时前
FastAPI+Ollama 部署本地AI大模型对话助手
python·github·aigc·ollama
u13013015 小时前
GitHub 热榜项目:日榜(2026-09-18)
人工智能·github
troy1281 天前
Python 基础语法(九):Django/Flask/FastAPI 三大 Web 框架详细对比解析
python·jupyter·django·flask·github·fastapi
dong_junshuai1 天前
每天一个开源项目#103 BrowserSkill:4.7K星,Agent接管真实浏览器
开源·github·agent
dong_junshuai1 天前
每天一个开源项目#102 六阶段代码复核流程范式
开源·github·agent