宝塔计划任务实现定时备份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
相关推荐
张居斜6 小时前
GitHub Actions + 阿里云 OSS:OIDC 免密同步构建产物
github·oss·llm-wiki
用户3228360084479 小时前
python-rapidjson:用 C++ 速度处理 JSON 的 Python 库
github
逛逛GitHub9 小时前
4 个比较实用的 GitHub 开源项目,浅浅的收藏一波。
github
Hommy889 小时前
【剪映小助手】添加贴纸接口(Add Sticker)
后端·github·剪映小助手·视频剪辑自动化·剪映api
2601_9618451512 小时前
粉笔行测5000题电子版|pdf|解析
pdf·新媒体运营·github·个人开发·内容运营·规格说明书·极限编程
用户7735300845115 小时前
gorillamux:Go语言路由库的实用选择
github
BBWEYY终身尊贵会员16 小时前
2026年6月四款建站工具怎么选?BBWEYY、比文云、GitHub Copilot、Dreamweaver 简明对比
github·copilot·dreamweaver
DogDaoDao16 小时前
【GitHub】CL4R1T4S:AI 系统提示词的透明革命
人工智能·python·ai·大模型·github·ai agent·cl4r1t4s
CHENG-JustDoIt17 小时前
AI工具 | 爆火开源项目Odysseus AI 工作台:从项目介绍、部署情况及其使用等多方位分析指南(含详细步骤)
大数据·人工智能·windows·python·ai·开源·github
MicrosoftReactor17 小时前
技术速递|从一次性提示到标准化工作流:如何在 GitHub Copilot CLI 中使用自定义智能体
github·copilot·cli·智能体