OpenClaw Backup
Overview
Automatically backup your complete OpenClaw configuration to a private GitHub repository. Features:
- - 🔐 API Key Sanitization - Automatically replaces sensitive keys before committing
- 🔄 Smart Backup Frequency - Hourly when active, daily when inactive
- 📦 Complete Backup - Agents, extensions, workspace, memory, and more
- 🔧 One-Click Recovery - Comprehensive recovery guide included
When to Use
- - After initial OpenClaw setup, establish a backup mechanism
- Periodic backup status checks
- System migration or disaster recovery
Quick Start
1. Prerequisites
- - Git installed
- GitHub SSH Key configured (recommended) or Personal Access Token
- GitHub private repository created (e.g.,
openclaw-backup)
2. Install Skill
Copy this skill to your OpenClaw workspace:
CODEBLOCK0
3. Run Installation Script
CODEBLOCK1
Follow the prompts to enter:
- - GitHub repository URL (e.g.,
git@github.com:yourname/openclaw-backup.git) - Git username and email
4. Configure Auto Backup
After installation, a cron job will be created in OpenClaw to check for backup needs every hour.
Usage
Manual Backup
CODEBLOCK2
Auto Backup (Based on Activity)
CODEBLOCK3
Check Activity Status
CODEBLOCK4
Restore from Backup
CODEBLOCK5
Follow the prompts:
- 1. Clone the backup repository
- Edit
openclaw.json to fill in real API keys - Restart Gateway
Backup Contents
| Included | Description |
|---|
| ✅ openclaw.json | Main configuration (API keys sanitized) |
| ✅ agents/ |
All agent session history |
| ✅ extensions/ | All plugins |
| ✅ workspace-*/ | Agent workspaces |
| ✅ memory/ | Agent memory databases |
| ✅ credentials/ | Credential configurations |
| ✅ feishu/ | Feishu configurations |
| ✅ wecom/ | WeChat Work configurations |
| Excluded | Reason |
|---|
| ❌ logs/ | Log files, can be regenerated |
Smart Backup Strategy
| Status | Condition | Backup Frequency |
|---|
| 🟢 Active | Activity within last hour | Every 1 hour |
| 🔴 Inactive |
No new activity | Every 24 hours |
Security Notes
⚠️ Important Security Warnings:
- 1. Must use a private repository - Backups contain sensitive configurations
- API Keys are sanitized - But other configs may still contain sensitive info
- Manual API key entry required on restore - Keys are replaced in backup files
File Structure
CODEBLOCK6
Troubleshooting
Push Failed
CODEBLOCK7
Configuration Lost After Restore
Ensure:
- 1. Edit
openclaw.json to fill in real API keys - Restart Gateway: INLINECODE4
Customization
Custom Backup Frequency
Edit heartbeat-state.json:
CODEBLOCK8
Add More Exclusions
Edit ~/.openclaw/.gitignore:
CODEBLOCK9
Author
OpenClaw Community
Version
- - v1.0.0 - Initial release with auto backup and smart frequency
OpenClaw 备份
概述
自动将完整的 OpenClaw 配置备份到私有 GitHub 仓库。功能特性:
- - 🔐 API 密钥清理 - 提交前自动替换敏感密钥
- 🔄 智能备份频率 - 活跃时每小时备份,非活跃时每日备份
- 📦 完整备份 - 包含代理、扩展、工作区、记忆等
- 🔧 一键恢复 - 附带完整恢复指南
使用场景
- - 完成 OpenClaw 初始配置后建立备份机制
- 定期检查备份状态
- 系统迁移或灾难恢复
快速开始
1. 前置条件
- - 已安装 Git
- 已配置 GitHub SSH 密钥(推荐)或个人访问令牌
- 已创建 GitHub 私有仓库(例如 openclaw-backup)
2. 安装技能
将此技能复制到您的 OpenClaw 工作区:
bash
确保技能目录存在
mkdir -p ~/.openclaw/workspace/skills
复制技能(假设已下载到当前目录)
cp -r openclaw-backup ~/.openclaw/workspace/skills/
3. 运行安装脚本
bash
一键配置
bash ~/.openclaw/workspace/skills/openclaw-backup/scripts/install.sh
根据提示输入:
- - GitHub 仓库 URL(例如 git@github.com:yourname/openclaw-backup.git)
- Git 用户名和邮箱
4. 配置自动备份
安装完成后,将在 OpenClaw 中创建一个定时任务,每小时检查备份需求。
使用方法
手动备份
bash
~/.openclaw/backup.sh backup
自动备份(基于活动状态)
bash
~/.openclaw/backup.sh auto
检查活动状态
bash
~/.openclaw/check-activity.sh
输出:active 或 inactive
从备份恢复
bash
~/.openclaw/backup.sh restore
根据提示操作:
- 1. 克隆备份仓库
- 编辑 openclaw.json 填写真实的 API 密钥
- 重启网关
备份内容
| 包含项 | 描述 |
|---|
| ✅ openclaw.json | 主配置文件(API 密钥已清理) |
| ✅ agents/ |
所有代理会话历史 |
| ✅ extensions/ | 所有插件 |
| ✅ workspace-*/ | 代理工作区 |
| ✅ memory/ | 代理记忆数据库 |
| ✅ credentials/ | 凭据配置 |
| ✅ feishu/ | 飞书配置 |
| ✅ wecom/ | 企业微信配置 |
智能备份策略
| 状态 | 条件 | 备份频率 |
|---|
| 🟢 活跃 | 过去一小时内存在活动 | 每 1 小时 |
| 🔴 非活跃 |
无新活动 | 每 24 小时 |
安全说明
⚠️ 重要安全警告:
- 1. 必须使用私有仓库 - 备份包含敏感配置
- API 密钥已清理 - 但其他配置可能仍包含敏感信息
- 恢复时需要手动输入 API 密钥 - 密钥在备份文件中已被替换
文件结构
~/.openclaw/
├── backup.sh # 主备份脚本
├── check-activity.sh # 活动状态检查器
├── .gitignore # Git 忽略配置
└── workspace/
└── memory/
└── heartbeat-state.json # 记录备份状态
故障排除
推送失败
bash
检查 SSH 连接
ssh -T git@github.com
强制推送(谨慎使用)
cd ~/.openclaw && git push origin main --force
恢复后配置丢失
请确保:
- 1. 编辑 openclaw.json 填写真实的 API 密钥
- 重启网关:openclaw gateway restart
自定义配置
自定义备份频率
编辑 heartbeat-state.json:
json
{
backup: {
activeInterval: 3600000,
inactiveInterval: 86400000
}
}
添加更多排除项
编辑 ~/.openclaw/.gitignore:
gitignore
自定义排除项
secrets/
*.pem
作者
OpenClaw 社区
版本
- - v1.0.0 - 初始版本,包含自动备份和智能频率