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
- Run backup:
bash ~/openclaw-backup.sh
-
Check backup succeeded.
-
Query current version and installed skills:
docker images | grep openclaw
docker exec openclaw-a npx clawhub list 2>/dev/null | grep "✓ ready"
- 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
- Restart the affected container if needed:
docker restart openclaw-a
- Run health checks — all must return 200:
curl -s -o /dev/null -w "%{http_code}" http://localhost:28791/healthz
- If 200 → cancel the auto-restore schedule:
rm ~/openclaw-pending-check
Write to death note: [timestamp] ✅ Health check passed. Restore cancelled.
- 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:
- Stops all openclaw containers
- Restores config from the latest backup
- Restarts containers
- Writes the incident to the death note
- 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.
