Agent State Backup
/install agent-state-backup
Agent State Backup & Restore
自动备份 OpenClaw 核心状态文件,防止上下文丢失。
📦 备份内容
IDENTITY.md- 身份定义SOUL.md- 人格定义MEMORY.md- 长期记忆memory/*.md- 每日记忆USER.md- 用户信息knowledge/**/*- 知识库
🚀 快速使用
手动备份
~/.openclaw/workspace/scripts/agent-backup.sh
手动恢复
~/.openclaw/workspace/scripts/agent-restore.sh
设置自动备份 (每日凌晨 2 点)
~/.openclaw/workspace/scripts/setup-backup-cron.sh
📁 文件位置
- 备份脚本:
~/.openclaw/workspace/scripts/agent-backup.sh - 恢复脚本:
~/.openclaw/workspace/scripts/agent-restore.sh - 备份目录:
~/.openclaw/backups/ - 保留策略: 最近 7 个备份
🔧 配置选项
编辑 ~/.openclaw/workspace/scripts/agent-backup.sh:
# 修改保留天数 (默认 7 天)
ls -t agent_backup_*.tgz | tail -n +8 | xargs -r rm
# 改为保留 30 天:tail -n +31
# 修改备份目录
BACKUP_DIR="$HOME/.openclaw/backups"
📊 备份日志
查看备份历史:
cat ~/.openclaw/backups/backup.log
⚠️ 注意事项
- 首次备份前 - 确保所有重要文件已保存
- 恢复操作 - 会覆盖当前文件,建议先备份当前状态
- 磁盘空间 - 每个备份约 20-50KB,7 个备份约 350KB
- Cron 权限 - 确保 cron 有权限访问工作目录
🔄 迁移到新环境
- 在新环境安装 OpenClaw
- 复制备份文件
.tgz到新机器 - 运行
agent-restore.sh - 重启 OpenClaw
版本: 1.0.0
最后更新: 2026-03-03
依赖: bash, tar, gzip
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install agent-state-backup - After installation, invoke the skill by name or use
/agent-state-backup - Provide required inputs per the skill's parameter spec and get structured output
What is Agent State Backup?
Auto-backs up core files (IDENTITY, SOUL, MEMORY, knowledge base) daily via cron, creates compressed .tgz archive, enables one-click restore in new environme... It is an AI Agent Skill for Claude Code / OpenClaw, with 169 downloads so far.
How do I install Agent State Backup?
Run "/install agent-state-backup" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Agent State Backup free?
Yes, Agent State Backup is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Agent State Backup support?
Agent State Backup is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Agent State Backup?
It is built and maintained by benxiao2026 (@benxiao2026); the current version is v1.0.0.