Set up automatic scheduled backups to GitHub or GitLab. Use when users want to backup their OpenClaw workspace or other directories. Supports GitHub CLI for easy repo creation. Works on macOS (launchd) and Linux (cron).
将任意目录自动定时备份到远程 Git 仓库。
当用户请求设置备份时,请按以下步骤操作:
默认值:~/.openclaw/workspace
如果 GitHub CLI (gh) 可用且已认证:
询问用户:
新建仓库:
bash
gh repo create <名称> --private --source=<备份路径> --remote=origin
已有仓库:
bash
如果没有 GitHub CLI:
bash
cat > ~/.openclaw/workspace/.backup-config.json << EOF
{
backupPath: <备份路径>,
gitRemote: <仓库URL>,
schedule: 0 12,0 *,
updateTimestamp: true
}
EOF
bash
mkdir -p ~/.openclaw/scripts
cp <技能路径>/scripts/backup.sh ~/.openclaw/scripts/github-backup.sh
chmod +x ~/.openclaw/scripts/github-backup.sh
macOS (launchd):
bash
bash <技能路径>/scripts/install-launchd.sh
Linux (cron):
bash
bash <技能路径>/scripts/install-cron.sh
bash
bash ~/.openclaw/scripts/github-backup.sh
设置完成后,用户可以:
| 命令 | 操作 |
|---|---|
| bash ~/.openclaw/scripts/github-backup.sh | 手动备份 |
| bash <技能路径>/scripts/manage.sh status |
配置文件:~/.openclaw/workspace/.backup-config.json
| 字段 | 默认值 | 描述 |
|---|---|---|
| backupPath | ~/.openclaw/workspace | 要备份的目录 |
| gitRemote |
检查 git 变更
└── 无变更 → 退出
└── 有变更 → 继续
↓
更新 README 时间戳(可选)
↓
git add . && git commit -m chore: 自动备份
↓
git push
| 文件 | 位置 |
|---|---|
| 备份脚本 | ~/.openclaw/scripts/github-backup.sh |
| 配置文件 |
用户:帮我配置 workspace 自动备份
Agent:
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 workspace-git-backup-1776200120 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 workspace-git-backup-1776200120 技能
skillhub install workspace-git-backup-1776200120
文件大小: 7.04 KB | 发布时间: 2026-4-15 13:40