gitclaw-backup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitClaw Backup

GitClaw 备份工具

Full backup of
/home/node/.openclaw/
to GitHub via git.
通过git将
/home/node/.openclaw/
目录全量备份到GitHub。

Quick Reference

快速参考

  • Repo:
    https://github.com/blessonism/openclaw-backup.git
  • Branch:
    main
  • Script:
    /home/node/.openclaw/gitclaw/auto_backup.sh
  • Cron:
    daily-workspace-backup
    — 每天 UTC 16:00 (北京时间 0:00)
  • Exclude rules:
    /home/node/.openclaw/.gitignore
  • Repo:
    https://github.com/blessonism/openclaw-backup.git
  • Branch:
    main
  • Script:
    /home/node/.openclaw/gitclaw/auto_backup.sh
  • Cron:
    daily-workspace-backup
    — 每天 UTC 16:00 (北京时间 0:00)
  • Exclude rules:
    /home/node/.openclaw/.gitignore

Manual Sync

手动同步

Run the backup script directly:
bash
bash /home/node/.openclaw/gitclaw/auto_backup.sh
Script behavior:
  • Lock-based (prevents concurrent runs)
  • Stages all changes (
    git add -A
    ), respects
    .gitignore
  • Skips commit if no changes
  • Pushes to
    origin main
  • Logs to
    /home/node/.openclaw/gitclaw/backup.log
直接运行备份脚本:
bash
bash /home/node/.openclaw/gitclaw/auto_backup.sh
脚本行为:
  • 基于锁实现(避免并发执行)
  • 暂存所有变更(
    git add -A
    ),遵循
    .gitignore
    规则
  • 无变更时跳过提交
  • 推送到
    origin main
    分支
  • 日志写入
    /home/node/.openclaw/gitclaw/backup.log

Post-Sync Response

同步后响应

After a successful sync, always include a clickable link to the latest commit in your reply:
bash
undefined
同步成功后,回复中必须包含指向最新commit的可点击链接:
bash
undefined

Get the latest commit short hash

获取最新commit短哈希

cd /home/node/.openclaw && git log --oneline -1

Then format the response like:

> ✅ 同步完成 — [查看 commit](https://github.com/blessonism/openclaw-backup/commit/<full_hash>)

- If no changes were detected, report "无变更,跳过" (no link needed).
- If the push failed, report the error and suggest troubleshooting steps.
cd /home/node/.openclaw && git log --oneline -1

然后按照如下格式返回:

> ✅ 同步完成 — [查看 commit](https://github.com/blessonism/openclaw-backup/commit/<full_hash>)

- 若无变更,返回「无变更,跳过」(无需提供链接)。
- 若推送失败,返回错误信息并给出排查建议。

Check Status

状态查询

bash
undefined
bash
undefined

Last backup log

查看最近备份日志

tail -5 /home/node/.openclaw/gitclaw/backup.log
tail -5 /home/node/.openclaw/gitclaw/backup.log

Git status (uncommitted changes)

查看Git状态(未提交变更)

cd /home/node/.openclaw && git status --short
cd /home/node/.openclaw && git status --short

Recent commits

查看最近提交记录

cd /home/node/.openclaw && git log --oneline -5
undefined
cd /home/node/.openclaw && git log --oneline -5
undefined

Exclude Files from Backup

配置备份排除文件

Edit
/home/node/.openclaw/.gitignore
— standard gitignore syntax.
Current notable exclusions:
workspace/images/
,
workspace/node_modules/
,
workspace/.micromamba/
,
workspace/bin/
, large binary files.
编辑
/home/node/.openclaw/.gitignore
即可,使用标准gitignore语法。
当前已默认排除的路径:
workspace/images/
workspace/node_modules/
workspace/.micromamba/
workspace/bin/
以及大型二进制文件。

Troubleshooting

问题排查

  • "already running" in log → stale lock at
    /home/node/.openclaw/gitclaw/lock/
    , remove it:
    rmdir /home/node/.openclaw/gitclaw/lock
  • Push rejected → likely force-push or diverged history on remote; check with
    git log --oneline -5 origin/main
  • Auth failure → credentials in
    ~/.git-credentials
    ; verify with
    git credential fill <<< "host=github.com"
  • 日志中出现「already running」→
    /home/node/.openclaw/gitclaw/lock/
    存在残留锁文件,执行以下命令删除:
    rmdir /home/node/.openclaw/gitclaw/lock
  • 推送被拒绝→大概率是远程分支存在强制推送或历史分叉,可执行
    git log --oneline -5 origin/main
    排查
  • 认证失败→凭证存储在
    ~/.git-credentials
    ,可执行
    git credential fill <<< "host=github.com"
    验证