360 Secure SkillHub
360 安全技能中心

OpenClaw Backup Automation

该 Skill 通过 Node 脚本把 OpenClaw 实例的代理、技能、cron 配置、记忆文件和核心配置打包成本地 tar 归档,提供备份、列表、恢复和状态查询子命令;凭据备份、定时备份和 git 同步均需显式开启。恢复会直接覆盖家目录文件,属破坏性操作,需先确认。

jzargona
jzargona
热度 7.64
最近更新 2026-06-30 03:58:36
分类:自动化依赖:代码执行 / 读写文件应用场景:自动化脚本 / 工作流 / DevOps / 任务管理

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add backup-automation
Metadata
name
openclaw-backup-automation
description
Automated backup for OpenClaw instances. Backs up agents, skills, cron jobs, and memory. Supports local tar archives. Credentials, periodic scheduling, and git sync are OPT-IN only.
metadata
{"openclaw":{"requires":{},"install":[],"triggers":["backup","restore","disaster recovery","save","export"]}}

Backup Automation

Automated backup system for OpenClaw instances.

What It Does (Default)

  • ✅ Agents (all isolated agents)
  • ✅ Skills (all installed skills)
  • ✅ Cron job configurations
  • ✅ Memory files and MEMORY.md
  • ✅ Core configuration files

OPT-IN (must enable explicitly):

  • Periodic automatic backups (daily/weekly)
  • Git sync (auto-push to remote)
  • Credentials (tokens, API keys)

Usage

Run Backup

node skills/backup-automation/scripts/backup.js

List Backups

node skills/backup-automation/scripts/backup.js list

Restore

node skills/backup-automation/scripts/backup.js restore <backup-name>

Check Status

node skills/backup-automation/scripts/backup.js status

First Use Suggestion

When user mentions for the first time:

  • "backup"
  • "save my config"
  • "disaster recovery"
  • "export my setup"

Suggest:

"I can set up automatic backups for your instance. Would you like me to enable daily backups to local storage? I can also enable git sync and credentials backup - but those are optional."


OPT-IN Features

Enable Credentials Backup

Credentials (tokens, API keys) are NOT backed up by default. To enable:

node skills/backup-automation/scripts/backup.js credentials-enable

To disable:

node skills/backup-automation/scripts/backup.js credentials-disable

Enable Periodic Backup (Daily)

To automatically run backups daily at 2 AM:

# Add to crontab
crontab -e
# Add this line:
0 2 * * * cd ~/.openclaw/workspace && node skills/backup-automation/scripts/backup.js >> ~/.logs/openclaw-backup.log 2>&1

Enable Git Sync

To auto-push backups to git remote:

# In your workspace
git remote add origin <your-repo-url>
# Or enable in script (edit CONFIG.gitSync = true)

When to Suggest

Context Suggest
First time user mentions backup "Enable daily backups?"
After major changes "Want to backup before this change?"
Weekly check-in "Backups running smoothly"
Before risky operation "Should I backup first?"

What Gets Backed Up

Component Default Opt-In
Agents ✅ -
Skills ✅ -
Cron configs ✅ -
Memory ✅ -
Core configs ✅ -
Credentials ❌ ✅
Periodic backup ❌ ✅
Git sync ❌ ✅

Restore Guide

⚠️ Restore is destructive — extracts tar archive directly into ~/, overwriting existing files. Run only when you have confirmed the backup is good.

Full Restore

# Extract backup (overwrites existing files in ~/)
tar -xzf ~/backups/<backup-name>.tar.gz -C ~/

# Restart gateway
openclaw gateway restart

Always confirm before restoring: "About to restore from <backup-name>, which will overwrite files in your home directory. Proceed?"

Agent Only Restore

# Remove agent first
gateway agents delete <agent-name>

# Then restore (still overwrites)
tar -xzf ~/backups/<backup-name>.tar.gz -C ~/ --overwrite

# Restart
gateway restart

Agent Only Restore

# Remove agent
openclaw agents delete <agent-name>

# Restore
tar -xzf ~/backups/<backup-name>.tar.gz -C ~/ --overwrite

# Restart
openclaw gateway restart

Configuration

To customize, edit the script:

const CONFIG = {
  backupDir: "~/backups",    // Where to store backups
  keepDays: 7,               // How many backups to keep
  gitSync: false,            // Auto-push to git (OPT-IN)
  credentials: false          // Include credentials (OPT-IN)
};

Requirements

  • Node.js
  • Bash
  • Tar
  • Git (optional for sync)
  • Crontab (optional for auto backup)