OpenClaw Backup & Auto-Restore (Synology NAS)
Automated backup and self-healing system for OpenClaw running on Synology NAS.
Environment
- Backup script:
/volume1/homes/$USER/openclaw-backup.sh - Restore script:
/volume1/homes/$USER/openclaw-restore.sh - List backups:
/volume1/homes/$USER/openclaw-list-backups.sh - Health watchdog:
/volume1/homes/$USER/openclaw-health-watchdog.sh - Notify config:
/volume1/homes/$USER/openclaw-notify.conf(private, not published) - Death note log:
/volume1/homes/$USER/openclaw-death-note.log - Pending check file:
/volume1/homes/$USER/openclaw-pending-check - Restore lock file:
/volume1/homes/$USER/openclaw-restore-lock - Backup directory:
/volume1/homes/$USER/openclaw-backups/(keeps 3 days)
Replace
$USERwith your Synology username.
Rules — Follow Every Time You Edit OpenClaw Config Files
Before Editing
- Run backup:
bash /volume1/homes/$USER/openclaw-backup.sh
- Write to death note:
[timestamp] 📝 File: <full path>
[timestamp] Purpose: <why you're changing it>
[timestamp] Change: <what exactly changed>
- Start watchdog timer:
date +%s > /volume1/homes/$USER/openclaw-pending-check
After Editing
-
Restart the affected container if needed.
-
Run health checks — all must return 200:
curl -s -o /dev/null -w "a: %{http_code}\n" http://localhost:28791/healthz
curl -s -o /dev/null -w "b: %{http_code}\n" http://localhost:28891/healthz
curl -s -o /dev/null -w "c: %{http_code}\n" http://localhost:28991/healthz
- All 200 → cancel watchdog and log result:
rm /volume1/homes/$USER/openclaw-pending-check
- If health check fails → check docker logs, write to death note, wait for watchdog to auto-restore.
Auto-Restore Mechanism
- Watchdog runs every minute via Synology Task Scheduler
- If 10 minutes pass without confirmed health → watchdog checks each container
- Only failed containers are restored (not all three)
- Notifies via LINE, Telegram, and Gmail
- 30-minute cooldown after restore to prevent infinite loops
Manual Operations
List all backups:
bash /volume1/homes/$USER/openclaw-list-backups.sh
Restore latest backup:
bash /volume1/homes/$USER/openclaw-restore.sh
Restore specific backup:
bash /volume1/homes/$USER/openclaw-restore.sh /volume1/homes/$USER/openclaw-backups/openclaw-backup-YYYYMMDD-HHMMSS.tar.gz
Cancel scheduled restore:
rm /volume1/homes/$USER/openclaw-pending-check
Pause watchdog for 30 minutes:
date +%s > /volume1/homes/$USER/openclaw-restore-lock
View death note:
cat /volume1/homes/$USER/openclaw-death-note.log
