宝塔计划任务实现定时备份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
相关推荐
啵啵肠1 天前
给 AI Agent 一把求职 CLI:推荐一个面向 BOSS 直聘工作流的开源项目 boss-agent-cli
人工智能·github
谷哥的小弟1 天前
(最新版)Git&GitHub实操图文详解教程(03)—Git工作原理
git·github·版本控制·工作原理·git工作原理
STDD1 天前
Teeworlds / DDNet 服务器搭建:经典 2D 竞技平台游戏
服务器·游戏·github
STDD1 天前
Alien Swarm《异星虫群》: Reactive Drop 专用服务器搭建教程
运维·服务器·github
OpenTiny社区1 天前
2026 OpenTiny NEXT 产品调研启动!
前端·开源·github
逛逛GitHub1 天前
推荐 8 个本周 YYDS 的 GitHub 开源项目。
github
逛逛GitHub1 天前
这个 GitHub 上 1.6 万人点赞 AI PPT 工具,生成的 PPT 能编辑。
github
stereohomology2 天前
ChatGPT对我首个Github开源的MCP的点评
chatgpt·开源·github
xiaoliuliu123452 天前
ArcGIS Pro 3.5.4专业桌面地理信息系统安装教程 Windows版:运行库+升级包+汉化补丁指南
github
_大学牲2 天前
从零实现自己的agent第六期:Agent Team团队协作
github·agent·ai编程