Self Backup
Backup critical OpenClaw workspace files to your GitHub repository for safe keeping and version control.
Setup
1. Install GitHub CLI (if not already installed)
CODEBLOCK0
2. Login to GitHub
CODEBLOCK1
3. Configure your backup repository
Edit the configuration in the backup script or set environment variables:
CODEBLOCK2
4. Create your backup repository
CODEBLOCK3
What Gets Backed Up
Core Configuration Files
- -
AGENTS.md - Workflow documentation and procedures - INLINECODE1 - Personal assistant personality and behavior
- INLINECODE2 - Personal profile and preferences
- INLINECODE3 - Long-term memory and important context
- INLINECODE4 - Assistant identity and emoji
- INLINECODE5 - Tool configuration and local notes
- INLINECODE6 - Cron and scheduling documentation
- INLINECODE7 - OpenClaw system settings (tokens sanitized for security)
Scripts & Automation
- -
scripts/ directory - All automation scripts - INLINECODE9 directory - Daily memory logs (last 30 days)
- Custom configuration files
Skills Configuration
- -
skills/ directory - Local skill installations (metadata only) - Skill customizations
Repository Structure
Files are organized in the backup repository as:
CODEBLOCK4
Usage
First-time setup:
CODEBLOCK5
Regular backups:
CODEBLOCK6
Options:
CODEBLOCK7
Security Features
- - Automatic token sanitization: All sensitive tokens (Discord, Telegram, API keys) are automatically redacted
- Private repository recommended: Keep your configuration private
- Structure preservation: All settings preserved, only sensitive data redacted
- Safe restore: Easy to restore and re-enter tokens
Configuration
Edit these variables in scripts/backup.sh:
CODEBLOCK8
Manual Backup
To backup specific files manually:
CODEBLOCK9
Restore Process
To restore from backup:
CODEBLOCK10
Troubleshooting
GitHub Authentication Issues
CODEBLOCK11
Permission Denied
CODEBLOCK12
Git Configuration
CODEBLOCK13
自我备份
将关键的OpenClaw工作区文件备份到您的GitHub仓库,以确保安全保存和版本控制。
设置
1. 安装GitHub CLI(如果尚未安装)
bash
Ubuntu/Debian
sudo apt install gh
macOS
brew install gh
其他平台:https://cli.github.com/
2. 登录GitHub
bash
gh auth login
3. 配置您的备份仓库
在备份脚本中编辑配置或设置环境变量:
bash
设置您的仓库URL(替换为您的仓库)
export BACKUP
REPOURL=https://github.com/YOUR
USERNAME/YOURBACKUP_REPO.git
或直接编辑脚本
nano scripts/backup.sh
4. 创建您的备份仓库
bash
为您的备份创建一个私有仓库
gh repo create YOUR_USERNAME/openclaw-backup --private --description OpenClaw工作区备份
备份内容
核心配置文件
- - AGENTS.md - 工作流文档和流程
- SOUL.md - 个人助手个性与行为
- USER.md - 个人资料与偏好
- MEMORY.md - 长期记忆与重要上下文
- IDENTITY.md - 助手身份与表情符号
- TOOLS.md - 工具配置与本地笔记
- AUTOMATION.md - 定时任务与调度文档
- openclaw.json - OpenClaw系统设置(令牌已脱敏以确保安全)
脚本与自动化
- - scripts/ 目录 - 所有自动化脚本
- memory/ 目录 - 每日记忆日志(最近30天)
- 自定义配置文件
技能配置
- - skills/ 目录 - 本地技能安装(仅元数据)
- 技能自定义设置
仓库结构
文件在备份仓库中的组织方式如下:
/
├── config/ # 核心配置文件
├── scripts/ # 自动化脚本
├── memory/ # 每日记忆日志
├── skills/ # 技能配置
└── backup-info.md # 备份元数据
使用方法
首次设置:
bash
scripts/setup.sh
定期备份:
bash
scripts/backup.sh
选项:
bash
scripts/backup.sh --force # 即使有冲突也强制推送
scripts/backup.sh --dry-run # 显示将要备份的内容
安全特性
- - 自动令牌脱敏:所有敏感令牌(Discord、Telegram、API密钥)会自动被遮蔽
- 推荐使用私有仓库:保持您的配置私密
- 结构保留:所有设置均保留,仅敏感数据被遮蔽
- 安全恢复:易于恢复并重新输入令牌
配置
编辑 scripts/backup.sh 中的以下变量:
bash
您的GitHub仓库URL
REPO
URL=https://github.com/YOURUSERNAME/YOUR
BACKUPREPO.git
工作区目录(通常自动检测)
WORKSPACE_DIR=$HOME/.openclaw/workspace
手动备份
手动备份特定文件:
bash
克隆您的备份仓库
git clone https://github.com/YOUR
USERNAME/YOURBACKUP_REPO.git /tmp/backup
cd /tmp/backup
复制重要文件
cp ~/.openclaw/workspace/AGENTS.md config/
cp ~/.openclaw/workspace/SOUL.md config/
... 等等
提交并推送
git add .
git commit -m 手动备份 $(date)
git push origin main
恢复流程
从备份中恢复:
bash
克隆备份
git clone https://github.com/YOUR
USERNAME/YOURBACKUP_REPO.git
将文件复制回工作区
cp backup/config/* ~/.openclaw/workspace/
cp -r backup/scripts/* ~/.openclaw/workspace/scripts/
... 等等
在openclaw.json中重新输入您的实际令牌
nano ~/.openclaw/openclaw.json
故障排除
GitHub认证问题
bash
重新登录GitHub
gh auth logout
gh auth login
权限被拒绝
bash
检查仓库是否存在以及您是否有访问权限
gh repo view YOUR
USERNAME/YOURBACKUP_REPO
Git配置
bash
如有需要,设置git身份信息
git config --global user.name 您的姓名
git config --global user.email 您的邮箱@example.com