360 Secure SkillHub
360 安全技能中心

Openclaw Backup

该 Skill 面向运行在 Docker 中的 OpenClaw,先备份配置,编辑后检查容器健康接口,健康则取消恢复,不健康则由定时看门狗从最近备份自动恢复并记录日志,同时提供 30 分钟冷却锁防止循环恢复。仅支持 Linux。

crazydb911
crazydb911
热度 20.93
最近更新 2026-03-19 02:01:48
分类:自动化依赖:代码执行 / 读写文件应用场景:自动化脚本 / DevOps / 工作流 / 日程安排

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add openclaw-backup-linux
Metadata
name
openclaw-backup
version
1.0.0
description
Auto backup, health check, and restore for OpenClaw running in Docker on any Linux system. Before editing config files, backs up automatically. After editing, confirms containers are healthy and cancels restore if OK — or auto-restores from backup if not.
homepage
https://github.com/crazydb911/openclaw-backup
metadata
{"clawdbot":{"emoji":"🦞","requires":{"bins":["bash","curl","docker"]}}}

OpenClaw Backup & Auto-Restore (General / Linux)

Automated backup and self-healing system for OpenClaw running in Docker on any Linux system.

Configuration

Set these variables to match your environment:

Variable Default Description
BACKUP_BASE ~/openclaw-backups Where backups are stored
BACKUP_SCRIPT ~/openclaw-backup.sh Path to backup script
DEATH_NOTE ~/openclaw-death-note.log Incident log
PENDING_FILE ~/openclaw-pending-check Watchdog trigger file
RESTORE_LOCK ~/openclaw-restore-lock Cooldown lock file
CONTAINER_NAMES openclaw-a openclaw-b Your container names
HEALTH_PORTS 28791 28891 Health check ports

Rules — Follow Every Time You Edit OpenClaw Config Files

Before Editing

  1. Run backup:
bash ~/openclaw-backup.sh
  1. Check backup succeeded.

  2. Query current version and installed skills:

docker images | grep openclaw
docker exec openclaw-a npx clawhub list 2>/dev/null | grep "✓ ready"
  1. Write to death note (~/openclaw-death-note.log):
[timestamp] 📝 File: <full path>
[timestamp] Purpose: <why you're changing it>
[timestamp] Change: <what exactly changed>
[timestamp] Version: <image ID>
[timestamp] Skills: <list of ✓ ready skills>

After Editing

  1. Restart the affected container if needed:
docker restart openclaw-a
  1. Run health checks — all must return 200:
curl -s -o /dev/null -w "%{http_code}" http://localhost:28791/healthz
  1. If 200 → cancel the auto-restore schedule:
rm ~/openclaw-pending-check

Write to death note: [timestamp] ✅ Health check passed. Restore cancelled.

  1. If health check fails → check logs, find root cause, write to death note:
docker logs --tail 30 openclaw-a

Auto-Restore Mechanism

A cron job (* * * * *) runs a watchdog script every minute. If 5 minutes pass without a confirmed health check, the watchdog:

  1. Stops all openclaw containers
  2. Restores config from the latest backup
  3. Restarts containers
  4. Writes the incident to the death note
  5. Sets a 30-minute cooldown lock to prevent infinite restore loops

Manual Operations

Cancel scheduled restore:

rm ~/openclaw-pending-check

Pause watchdog for 30 minutes:

date +%s > ~/openclaw-restore-lock

View death note:

cat ~/openclaw-death-note.log

Setup

1. Download scripts

curl -O https://raw.githubusercontent.com/crazydb911/openclaw-backup/main/scripts/openclaw-backup.sh
curl -O https://raw.githubusercontent.com/crazydb911/openclaw-backup/main/scripts/openclaw-restore-watchdog.sh
chmod +x openclaw-backup.sh openclaw-restore-watchdog.sh

2. Edit variables at the top of each script to match your environment.

3. Add cron jobs:

# Edit crontab
crontab -e

# Add these two lines:
0 */6 * * * bash ~/openclaw-backup.sh >> ~/openclaw-backup.log 2>&1
* * * * * bash ~/openclaw-restore-watchdog.sh >> ~/openclaw-backup.log 2>&1

4. Install this skill in OpenClaw:

npx clawhub install openclaw-backup

See the repository homepage for the full guide.