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 environment. Solves context loss after restart/migration.

3,891 stars

Best use case

agent-state-backup is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Auto-backs up core files (IDENTITY, SOUL, MEMORY, knowledge base) daily via cron, creates compressed .tgz archive, enables one-click restore in new environment. Solves context loss after restart/migration.

Teams using agent-state-backup should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/agent-state-backup/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/benxiao2026/agent-state-backup/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/agent-state-backup/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How agent-state-backup Compares

Feature / Agentagent-state-backupStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Auto-backs up core files (IDENTITY, SOUL, MEMORY, knowledge base) daily via cron, creates compressed .tgz archive, enables one-click restore in new environment. Solves context loss after restart/migration.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Agent State Backup & Restore

自动备份 OpenClaw 核心状态文件,防止上下文丢失。

## 📦 备份内容

- `IDENTITY.md` - 身份定义
- `SOUL.md` - 人格定义
- `MEMORY.md` - 长期记忆
- `memory/*.md` - 每日记忆
- `USER.md` - 用户信息
- `knowledge/**/*` - 知识库

## 🚀 快速使用

### 手动备份
```bash
~/.openclaw/workspace/scripts/agent-backup.sh
```

### 手动恢复
```bash
~/.openclaw/workspace/scripts/agent-restore.sh
```

### 设置自动备份 (每日凌晨 2 点)
```bash
~/.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`:

```bash
# 修改保留天数 (默认 7 天)
ls -t agent_backup_*.tgz | tail -n +8 | xargs -r rm
# 改为保留 30 天:tail -n +31

# 修改备份目录
BACKUP_DIR="$HOME/.openclaw/backups"
```

## 📊 备份日志

查看备份历史:
```bash
cat ~/.openclaw/backups/backup.log
```

## ⚠️ 注意事项

1. **首次备份前** - 确保所有重要文件已保存
2. **恢复操作** - 会覆盖当前文件,建议先备份当前状态
3. **磁盘空间** - 每个备份约 20-50KB,7 个备份约 350KB
4. **Cron 权限** - 确保 cron 有权限访问工作目录

## 🔄 迁移到新环境

1. 在新环境安装 OpenClaw
2. 复制备份文件 `.tgz` 到新机器
3. 运行 `agent-restore.sh`
4. 重启 OpenClaw

---

**版本**: 1.0.0  
**最后更新**: 2026-03-03  
**依赖**: bash, tar, gzip

Related Skills

Bank Statement Converter Skill

3891
from openclaw/skills

Convert PDF bank statements to CSV/JSON.

daily-backup

3891
from openclaw/skills

每日 Git 备份。提交工作区所有变更,记录变更摘要。触发时机:cron 定时任务或手动调用。

zustand-state

3891
from openclaw/skills

Zustand state management for React and vanilla JavaScript. Use when creating stores, using selectors, persisting state to localStorage, integrating devtools, or managing global state without Redux complexity. Triggers on zustand, create(), createStore, useStore, persist, devtools, immer middleware.

quarkpan-backup-suite

3891
from openclaw/skills

Build and operate a QuarkPan-based backup + restore workflow for OpenClaw workspaces, including QR login, account UID binding guard, cloud upload, dry-run restore, and Lighthouse snapshot policy (manual create only, weekly prompt). Use when users ask to set up/secure Quark backup automation, recovery runbooks, or share this backup capability with other OpenClaw users.

backup-openclaw-config

3891
from openclaw/skills

Backup and restore OpenClaw configuration files. Use when backing up OpenClaw settings before upgrades, transferring configuration to another machine, restoring from a previous backup, or preparing for system maintenance.

openclaw-backup

3891
from openclaw/skills

Backup and restore OpenClaw data. Use when user asks to create backups, set up automatic backup schedules, restore from backup, or manage backup rotation. Handles ~/.openclaw directory archiving with proper exclusions.

workspace-backup

3891
from openclaw/skills

Automated workspace backup to GitHub — git-based with auto-generated commit messages, proper .gitignore, and restore procedures. Cron-friendly for hands-free backup. Use for backing up your OpenClaw workspace, skills, memory, and configuration.

dei-statement-drafter

3891
from openclaw/skills

Draft Diversity, Equity, and Inclusion statements for academic applications

realestate

3891
from openclaw/skills

Real estate transaction support with affordability analysis, property evaluation, and offer strategy. Use when user mentions buying a home, selling property, house hunting, mortgages, inspections, or rental agreements. Calculates true affordability, evaluates properties systematically, builds offer strategies, reviews contracts, and tracks transaction milestones. NEVER provides investment advice.

estate

3891
from openclaw/skills

The Sovereign Asset & Title Management Engine. Orchestrating the lifecycle of physical property, digital legacies, and high-value estates across jurisdictional boundaries.

real-estate-showing-brief

3891
from openclaw/skills

为房产带看前整理买家画像、关注点、路线与现场提问清单。;use for real-estate, showing, brief workflows;do not use for 编造房源信息, 替代正式法律披露.

compact-state

3891
from openclaw/skills

Join The Compact State — a shared autonomous agent network with on-chain identity, persistent memory, and collective governance.