宝塔计划任务实现定时备份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
相关推荐
wangruofeng9 小时前
opencodex 解锁 Codex 任意模型,一个本地代理打通 Claude/Kimi/GLM/DeepSeek
llm·github·openai
一点一木10 小时前
从60首歌到1个网站:输入你的故事,还你一首歌
前端·github
刘较瘦_15 小时前
AI 开发中的 Git Submodule 父子仓库模式:前后端分仓管理与协作实践
前端·github
DeMinds18 小时前
内容没有丢,我为什么总在重新整理?|DeMinds 如何让工作接着继续
ios·github·markdown
寒水馨18 小时前
macOS下载、安装openclaw-v2026.7.1(附安装包OpenClaw-2026.7.1.dmg)
macos·大模型·github·开源软件·ai助手·openclaw·gpt-5.6
徐小夕19 小时前
花了3天,我写了一款开源AI公众号编辑器
前端·vue.js·github
CCPC不拿奖不改名1 天前
大模型推理架构与开源生态知识整理
数据库·windows·python·架构·langchain·开源·github
redreamSo2 天前
一天涨 1800 星的 GitHub 榜首:AI 编程瓶颈变成了 token
人工智能·开源·github
小弥儿2 天前
GitHub今日热榜 | 2026-07-20:AI Agent 知识体系迎来系统化梳理
学习·开源·github