用途
git-crypt-backup 用于把 Clawdbot 的工作区(~/clawd)和配置(~/.clawdbot)备份到 GitHub,并通过 git-crypt 对敏感文件进行加密。可用于每日自动备份,也可用于手动备份与恢复操作。
主要能力
- 将工作区与配置分别推送到两个 GitHub 仓库(建议使用私有仓库)。
- 使用 git-crypt 对指定文件进行加密,未列入加密规则的文件以明文保存。
- 提供每日备份脚本 scripts/backup.sh,也可配置 cron 定时任务实现自动每日备份。
- 支持在新机器上通过克隆仓库并用导出的密钥解锁来恢复。
使用方式
1. 创建 GitHub 仓库
在 GitHub 上创建两个私有仓库(推荐):
- <username>/clawdbot-workspace
- <username>/clawdbot-config
2. 初始化 git-crypt
安装 git-crypt:
brew install git-crypt # macOS
apt install git-crypt # Linux
工作区仓库:
cd ~/clawd
git init
git-crypt init
git remote add origin git@github.com:<username>/clawdbot-workspace.git
配置仓库:
cd ~/.clawdbot
git init
git-crypt init
git remote add origin git@github.com:<username>/clawdbot-config.git
3. 配置加密
工作区 .gitattributes:
SOUL.md filter=git-crypt diff=git-crypt
USER.md filter=git-crypt diff=git-crypt
HEARTBEAT.md filter=git-crypt diff=git-crypt
MEMORY.md filter=git-crypt diff=git-crypt
memory/** filter=git-crypt diff=git-crypt
配置 .gitattributes:
clawdbot.json filter=git-crypt diff=git-crypt
.env filter=git-crypt diff=git-crypt
credentials/** filter=git-crypt diff=git-crypt
telegram/** filter=git-crypt diff=git-crypt
identity/** filter=git-crypt diff=git-crypt
agents/**/sessions/** filter=git-crypt diff=git-crypt
nodes/** filter=git-crypt diff=git-crypt
配置 .gitignore:
*.bak
*.bak.*
.DS_Store
logs/
media/
browser/
subagents/
memory/
update-check.json
*.lock
4. 导出密钥(重要)
mkdir -p ~/clawdbot-keys
cd ~/clawd && git-crypt export-key ~/clawdbot-keys/workspace.key
cd ~/.clawdbot && git-crypt export-key ~/clawdbot-keys/config.key
密钥需安全保存(如 1Password、iCloud Keychain、USB 驱动器等)。
5. 初始提交与推送
cd ~/clawd && git add -A && git commit -m "Initial backup" && git push -u origin main
cd ~/.clawdbot && git add -A && git commit -m "Initial backup" && git push -u origin main
每日备份
运行 scripts/backup.sh:
~/clawd/skills/git-crypt-backup/scripts/backup.sh
或设置 cron 任务实现每日自动备份。
在新机器上恢复
# 1. 克隆仓库
git clone git@github.com:<username>/clawdbot-workspace.git ~/clawd
git clone git@github.com:<username>/clawdbot-config.git ~/.clawdbot
# 2. 用密钥解锁
cd ~/clawd && git-crypt unlock /path/to/workspace.key
cd ~/.clawdbot && git-crypt unlock /path/to/config.key
加密范围
| 仓库 | 加密 | 明文 |
|---|---|---|
| workspace | SOUL/USER/HEARTBEAT/MEMORY.md, memory/** | AGENTS.md, IDENTITY.md, TOOLS.md, drafts/** |
| config | clawdbot.json, .env, credentials/, sessions/ | cron/jobs.json, settings/** |
适用场景
- 需要定期把 Clawdbot 工作区与配置备份到 GitHub 的用户。
- 希望敏感文件(如记忆、凭据、会话等)在仓库中保持加密状态的用户。
- 需要在新机器上快速恢复工作区与配置的场景。
限制
- 依赖 git-crypt 与 GitHub 仓库,需自行创建仓库并配置远程地址。
- 密钥需自行安全保存,丢失密钥将无法解锁加密文件。
- 资料未提供其他平台支持、收费或价格信息。