360 Secure SkillHub
360 安全技能中心

Openclaw Backup Nas

面向 Synology NAS 上运行的 OpenClaw:编辑配置前自动备份并记录死亡笔记,编辑后检查三个容器的健康状态,若 10 分钟内未确认健康,则由每分钟运行的 watchdog 仅还原失败的容器,并通过 LINE、Telegram、Gmail 通知,另附手动备份、列表与还原脚本。

crazydb911
crazydb911
热度 19.68
最近更新 2026-03-19 05:01:48
分类:自动化依赖:代码执行 / 读写文件 / 第三方 API应用场景:自动化脚本 / DevOps / 工作流

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add openclaw-backup-nas
Metadata
name
openclaw-backup-nas
version
2.0.0
description
Auto backup, health check, and per-container restore for OpenClaw on Synology NAS. Backs up before edits, confirms health after, and auto-restores only failed containers if health check fails within 10 minutes.
homepage
https://github.com/crazydb911/openclaw-backup-nas
metadata
{"clawdbot":{"emoji":"🦞","requires":{"bins":["bash","curl","python3","tar"]}}}

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 $USER with your Synology username.

Rules — Follow Every Time You Edit OpenClaw Config Files

Before Editing

  1. Run backup:
bash /volume1/homes/$USER/openclaw-backup.sh
  1. Write to death note:
[timestamp] 📝 File: <full path>
[timestamp] Purpose: <why you're changing it>
[timestamp] Change: <what exactly changed>
  1. Start watchdog timer:
date +%s > /volume1/homes/$USER/openclaw-pending-check

After Editing

  1. Restart the affected container if needed.

  2. 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
  1. All 200 → cancel watchdog and log result:
rm /volume1/homes/$USER/openclaw-pending-check
  1. 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