/install claw-saver
claw-saver
Back up the entire OpenClaw environment (~/.openclaw) to a Git repository. Supports scheduled backups, interactive restore, and exponential backoff on network failures.
Features
- Full backup: Everything in ~/.openclaw is backed up, including agents, skills, configurations, knowledge bases, and agent memory
- Smart exclusions: Only ignores clearly harmless runtime artifacts (logs, cache, node_modules, canvas)
- Scheduled backups: Configurable cron schedule (default: every 5 hours)
- Atomic commits: Two-commit strategy ensures backup files and restore guide are always consistent
- Git LFS support: Large model files are auto-tracked via Git LFS
- Exponential backoff: Failed pushes retry with 60s -> 120s -> 240s delays
- Stale lock protection: Orphan backup processes are detected and cleaned up
- Dynamic .gitignore: Scans the actual directory structure, no hardcoded assumptions
Quick Start
# 1. Configure your Git token
openclaw config set env.OPENCLAW_BACKUP_GIT_TOKEN \x3Cyour-token>
# 2. Set your repository URL
# Edit ~/.openclaw/skills/claw-saver/config.json and set "repo"
# Example: "repo": "https://cnb.cool/yourname/your-repo"
# 3. Run your first backup
openclaw backup run
# 4. Enable automatic backups (every 5 hours)
openclaw backup enable-cron
CLI Commands
openclaw backup run # Run backup immediately
openclaw backup status # Show last backup time and commit hash
openclaw backup restore # Restore from a previous commit (interactive)
openclaw backup enable-cron # Enable scheduled backups
openclaw backup disable-cron # Disable scheduled backups
openclaw backup set-cron \x3Cexpr> # Set custom schedule (e.g. "0 */2 * * *")
Configuration
Edit ~/.openclaw/skills/claw-saver/config.json:
{
"repo": "https://cnb.cool/yourname/your-repo",
"cron": "0 */5 * * *",
"lfs_threshold_mb": 10,
"lfs_extensions": [".bin", ".gguf", ".safetensors", ".pt", ".pth", ".onnx", ".msgpack", ".model"],
"push_retries": 3,
"push_retry_interval_ms": 60000
}
| Option | Default | Description |
|---|---|---|
repo |
(required) | Git repository URL |
cron |
0 */5 * * * |
Backup schedule (cron expression, in system timezone) |
lfs_threshold_mb |
10 |
Files larger than this are tracked via Git LFS |
lfs_extensions |
(see above) | File extensions to LFS-track |
push_retries |
3 |
Max push retry attempts on failure |
push_retry_interval_ms |
60000 |
Initial retry delay (doubles each attempt) |
What Is Backed Up
Everything except harmless runtime artifacts:
# === BACKED UP ===
agents/ # Agent configurations, auth profiles, session data
credentials/ # Channel credentials and keys
identity/ # Device identity keys
kb/ # Knowledge base (user docs + vector database)
lts/ # Long-term scripts (cleanup, OOM protection)
openclaw.json # Core configuration (含 tokens)
skills/ # All installed skills and their configs
workspace-* / # Agent workspaces, memory, learnings
**/.learnings/ # Agent self-improvement logs
**/.openclaw/ # Per-workspace OpenClaw state
And all other directories in ~/.openclaw/
What Is Excluded (Runtime Artifacts Only)
These are transient or rebuildable and intentionally not backed up:
.git/ # Git repository itself (local only)
logs/ # Runtime logs
canvas/ # Canvas runtime state
media/ # Uploaded media files
npm/ # NPM packages (rebuild with npm install)
cron/runs/ # Cron execution history
**/node_modules/ # Dependencies (rebuild with npm install / pip install)
**/__pycache__/ # Python bytecode cache
**/.cache/ # Generic cache
**/dreaming/ # Short-term memory state
*.tmp, *.bak # OS noise
.backup.lock # Runtime lock file
User data principle: If in doubt, it is backed up. Credentials, identity keys, knowledge bases, agent memory, and learned data are all preserved.
Security
- Token isolation: The token is stored only in
~/.openclaw/.git/config(local, never pushed to the backup repo) and in the cron environment variable (local system only) - No token in commits: RESTORE.md and commit messages contain only the repo URL, never the token
- stderr suppressed:
git pushstderr is redirected to prevent token leakage in error messages - git directory excluded:
.git/is in .gitignore, so.git/config(containing the token in the remote URL) is never backed up
Restore
openclaw backup restore
This clones the repository to a temp directory, checks out the specified commit, and copies files back to ~/.openclaw. A running backup is preserved (skills/claw-saver stays live during restore).
After restore completes:
openclaw gateway restart
Restore Guide
A RESTORE.md file is generated with each backup, embedded in the backup commit. It contains the exact commit hash, clone instructions, and a list of what was excluded so you know what needs manual restoration.
Architecture
skills/claw-saver/
lib/
backup.js # Core orchestration (lock, stage, commit, push)
git.js # Git operations (init, add, commit, push, clone)
lfs.js # Git LFS setup and tracking
restore.js # Interactive restore logic
scripts/
cli.js # CLI entry point (run, status, restore, cron)
config.json # User configuration (repo, cron, LFS settings)
Lock Mechanism
Concurrent backup runs are prevented via an atomic mkdir-based lock:
- Lock dir:
~/.openclaw/.backup.lock/(pid file inside) - If a stale lock is detected (holder PID is dead), it is forcibly taken over
- Lock is always released via
finally{}after backup completes or fails
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install claw-saver - 安装完成后,直接呼叫该 Skill 的名称或使用
/claw-saver触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
claw-saver 是什么?
Back up the full OpenClaw environment (~/.openclaw) to a Git repository. Supports scheduled backups, interactive restore, and Git LFS for large model files. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 157 次。
如何安装 claw-saver?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install claw-saver」即可一键安装,无需额外配置。
claw-saver 是免费的吗?
是的,claw-saver 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
claw-saver 支持哪些平台?
claw-saver 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 claw-saver?
由 Jixson(@jixsonwang)开发并维护,当前版本 v1.6.2。