返回顶部
w

workspace-git-backup工作区Git备份

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).

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
278
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

workspace-git-backup

GitHub 备份

将任意目录自动定时备份到远程 Git 仓库。

设置流程

当用户请求设置备份时,请按以下步骤操作:

1. 询问备份目录

默认值:~/.openclaw/workspace

2. 配置远程仓库

如果 GitHub CLI (gh) 可用且已认证:

询问用户:

  • - 新建 GitHub 仓库 还是 同步到已有仓库?

新建仓库:
bash
gh repo create <名称> --private --source=<备份路径> --remote=origin

已有仓库:
bash

列出仓库


gh repo list --limit 50

添加远程仓库(用户提供仓库名称或 URL)

git -C <备份路径> remote add origin

如果没有 GitHub CLI:

  • - 直接询问用户仓库 URL

3. 创建配置文件

bash
cat > ~/.openclaw/workspace/.backup-config.json << EOF
{
backupPath: <备份路径>,
gitRemote: <仓库URL>,
schedule: 0 12,0 *,
updateTimestamp: true
}
EOF

4. 安装备份脚本

bash
mkdir -p ~/.openclaw/scripts
cp <技能路径>/scripts/backup.sh ~/.openclaw/scripts/github-backup.sh
chmod +x ~/.openclaw/scripts/github-backup.sh

5. 安装定时任务

macOS (launchd):
bash
bash <技能路径>/scripts/install-launchd.sh

Linux (cron):
bash
bash <技能路径>/scripts/install-cron.sh

6. 可选:首次备份

bash
bash ~/.openclaw/scripts/github-backup.sh

命令

设置完成后,用户可以:

命令操作
bash ~/.openclaw/scripts/github-backup.sh手动备份
bash <技能路径>/scripts/manage.sh status
查看状态 |
| bash <技能路径>/scripts/manage.sh logs | 查看日志 |
| bash <技能路径>/scripts/manage.sh uninstall | 移除定时任务 |

配置

配置文件:~/.openclaw/workspace/.backup-config.json

字段默认值描述
backupPath~/.openclaw/workspace要备份的目录
gitRemote
必填 | 仓库 URL |
| schedule | 0 12,0 * | Cron 表达式:每天 12:00 和 00:00 |
| updateTimestamp | true | 更新 README 时间戳 |

备份脚本逻辑

检查 git 变更
└── 无变更 → 退出
└── 有变更 → 继续

更新 README 时间戳(可选)

git add . && git commit -m chore: 自动备份

git push

创建的文件

文件位置
备份脚本~/.openclaw/scripts/github-backup.sh
配置文件
~/.openclaw/workspace/.backup-config.json | | 日志 | ~/.openclaw/logs/github-backup.log | | launchd plist | ~/Library/LaunchAgents/com.openclaw.github-backup.plist | | cron 条目 | 通过 crontab 添加 |

示例对话

用户:帮我配置 workspace 自动备份

Agent:

  1. 1. 检测 gh CLI → 已登录
  2. 新建仓库还是用已有的? → 新建
  3. 仓库名称? → openclaw-backup
  4. 公开还是私有? → 私有
  5. 执行:gh repo create openclaw-backup --private --source=~/.openclaw/workspace --remote=origin
  6. 创建配置文件
  7. 安装定时任务
  8. 安装完成,每天 12:00 和 00:00 自动备份

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 workspace-git-backup-1776200120 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 workspace-git-backup-1776200120 技能

通过命令行安装

skillhub install workspace-git-backup-1776200120

下载

⬇ 下载 workspace-git-backup v1.0.0(免费)

文件大小: 7.04 KB | 发布时间: 2026-4-15 13:40

v1.0.0 最新 2026-4-15 13:40
Initial release

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部