OpenClaw Backup & Restore
A specialized skill for managing the lifecycle of your OpenClaw data. This skill utilizes an external Git-managed backup directory to keep your production environment clean while ensuring full recoverability.
Strategy
- 1. Isolation: Git operations happen in a dedicated directory outside the live
.openclaw runtime to avoid pollution. - Minimalism: Large
node_modules, logs, and temporary files are excluded. - Redundancy: Regular backups can be scheduled via Cron.
Setup
Before using this skill, you must set your private backup repository URL in openclaw.json. This URL is used by the scripts to push and pull data.
CODEBLOCK0
How to Backup
To trigger a manual backup and sync to your remote repository:
- 1. The agent should execute the
backup.sh script located within this skill's scripts/ directory. - The script will:
- Read the repo URL from the OpenClaw config.
- Sync
${HOME}/.openclaw/ to
${HOME}/openclaw-backup/ using
rsync (respecting
.gitignore).
- Generate a readable commit summary from changed paths (for example workspace/config/runtime/memory).
- Commit and push to the remote
main branch.
Trigger Phrases: "Backup OpenClaw now", "Sync my data to GitHub".
How to Restore
To restore your environment on a new or existing machine:
- 1. Ensure your SSH key is added to your Git provider (e.g., GitHub).
- The agent should execute the
restore.sh script located within this skill's scripts/ directory. - The process involves:
- Reading the repo URL from the OpenClaw config.
- Cloning or pulling the latest backup from the configured repository.
- Syncing files back to
${HOME}/.openclaw/.
- Reinstalling node dependencies and running
openclaw doctor --yes to fix environment paths.
- 4. Restart the Gateway:
openclaw gateway restart.
Trigger Phrases: "Restore OpenClaw from backup", "Migrate my data".
Technical Details
- - Backup Directory: INLINECODE15
- Source Directory: INLINECODE16
- Exclusions: Defined in the skill's
.gitignore (includes node_modules/, logs/, completions/, tmp/, dist/). - Automatic Setup: The
.gitignore file is included in this skill and will be copied to ${HOME}/openclaw-backup/ during the first backup run.
Recovery Checklist
If restoring to a completely new machine:
- 1. Install OpenClaw CLI first.
- Set the
OPENCLAW_BACKUP_REPO config value. - Configure SSH access for your Git provider.
- Run the restore script provided by this skill.
- Run
openclaw onboard if you need to re-install the daemon service.
技能名称: openclaw-backup-restore
详细描述:
OpenClaw 备份与恢复
一项用于管理 OpenClaw 数据生命周期的专业技能。该技能利用外部 Git 管理的备份目录,在确保完全可恢复性的同时,保持生产环境的整洁。
策略
- 1. 隔离性:Git 操作在实时 .openclaw 运行环境之外的专用目录中进行,以避免污染。
- 极简主义:大型的 node_modules、日志和临时文件将被排除在外。
- 冗余性:可通过 Cron 定期安排备份。
设置
在使用此技能之前,您必须在 openclaw.json 中设置您的私有备份仓库 URL。该 URL 将被脚本用于推送和拉取数据。
bash
openclaw config set skills.entries.openclaw-backup-restore.env.OPENCLAWBACKUPREPO git@github.com:your-username/your-repo.git
如何备份
要触发手动备份并同步到您的远程仓库:
- 1. 代理应执行位于此技能 scripts/ 目录中的 backup.sh 脚本。
- 该脚本将:
- 从 OpenClaw 配置中读取仓库 URL。
- 使用 rsync 将 ${HOME}/.openclaw/ 同步到 ${HOME}/openclaw-backup/(遵循 .gitignore 规则)。
- 根据更改的路径(例如 workspace/config/runtime/memory)生成可读的提交摘要。
- 提交并推送到远程 main 分支。
触发短语:立即备份 OpenClaw,将我的数据同步到 GitHub。
如何恢复
要在新机器或现有机器上恢复您的环境:
- 1. 确保您的 SSH 密钥已添加到您的 Git 提供商(例如 GitHub)。
- 代理应执行位于此技能 scripts/ 目录中的 restore.sh 脚本。
- 该过程包括:
- 从 OpenClaw 配置中读取仓库 URL。
- 从配置的仓库克隆或拉取最新的备份。
- 将文件同步回 ${HOME}/.openclaw/。
- 重新安装 Node 依赖项并运行 openclaw doctor --yes 以修复环境路径。
- 4. 重启网关:openclaw gateway restart。
触发短语:从备份恢复 OpenClaw,迁移我的数据。
技术细节
- - 备份目录:${HOME}/openclaw-backup
- 源目录:${HOME}/.openclaw
- 排除项:在技能的 .gitignore 中定义(包括 node_modules/、logs/、completions/、tmp/、dist/)。
- 自动设置:.gitignore 文件包含在此技能中,并将在首次备份运行时复制到 ${HOME}/openclaw-backup/。
恢复检查清单
如果恢复到全新的机器:
- 1. 首先安装 OpenClaw CLI。
- 设置 OPENCLAWBACKUPREPO 配置值。
- 为您的 Git 提供商配置 SSH 访问。
- 运行此技能提供的恢复脚本。
- 如果需要重新安装守护进程服务,请运行 openclaw onboard。