← 返回 Skills 市场
neverland83

OC Backup

作者 FrankMei · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ 安全检测通过
107
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install oc-backup
功能描述
备份 OpenClaw 关键配置文件、核心数据和自定义技能,支持全量及分类备份,自动管理备份文件保留和清理。
使用说明 (SKILL.md)

OpenClaw 关键文件备份技能

元信息

  • 名称: openclaw-backup
  • 版本: 1.1.0
  • 描述: OpenClaw 关键文件备份技能,支持全量备份和分类备份,保护您的核心配置和自定义技能
  • 作者: FrankMei ([email protected])
  • 运行时: node18
  • 主入口: scripts/backup.js

功能说明

在 LLM 大模型的加持下,OpenClaw 功能很强大,但同时也很"傻"——它经常"自杀"(把 openclaw.json 等关键配置文件改坏,导致系统异常),也经常"自残"(把上一秒还能正常工作的 skill 搞得乱七八糟)。如果你也经常遇到这样的困扰,那就应该经常备份那些关键文件!这个 skill 就是帮你做这件事的。

备份 OpenClaw 运行所需的关键配置文件和用户数据,包括:

  • 系统配置: openclaw.json, .env, exec-approvals.json
  • 核心文件: AGENTS.md, SOUL.md, USER.md, IDENTITY.md, TOOLS.md, HEARTBEAT.md, MEMORY.md
  • 技能目录: skills/ 下所有自定义技能
  • 其他数据: cron/ 定时任务, devices/ 设备配置, memory/ 记忆数据

触发关键词

  • 备份
  • backup
  • openclaw backup

使用方式

基本用法

# 通过 OpenClaw Agent 调用
node scripts/backup.js [options]

# 或让 agent 执行备份操作

命令行参数

参数 简写 说明
--full -f 执行全量备份(默认)
--system -s 只备份系统配置
--workspace -w 只备份核心文件
--skills -k 只备份技能目录
--memory -m 只备份记忆数据
--cron -c 只备份定时任务配置
--devices -d 只备份设备配置
--output \x3Cpath> -o 指定输出目录
--dry-run 预览模式,显示将备份的文件但不实际执行
--retain \x3Cdays> 保留最近 N 天的备份,自动删除更早的备份
--clean 清理模式:只删除旧备份,不执行新备份
--json -j 以 JSON 格式输出结果

使用示例

命令行调用

# 全量备份
node scripts/backup.js

# 只备份技能目录
node scripts/backup.js --skills

# 组合备份
node scripts/backup.js --system --workspace

# 自定义输出位置
node scripts/backup.js --output /path/to/backup

# 预览模式
node scripts/backup.js --dry-run

# JSON 输出(供程序解析)
node scripts/backup.js --json

# 备份并只保留最近14天的备份
node scripts/backup.js --full --retain 14

# 只清理旧备份(不执行新备份)
node scripts/backup.js --clean --retain 14

# 预览将删除的旧备份
node scripts/backup.js --clean --retain 14 --dry-run

自然语言调用

你也可以直接对 OpenClaw 说以下话,让它帮你执行备份:

帮我备份一下 OpenClaw
备份 OpenClaw 所有配置
只备份我的技能目录
预览一下要备份哪些文件

OpenClaw 会识别你的意图并调用本技能完成备份操作。

Cron 定时任务

你可以在 OpenClaw 中设置定时任务,实现每天自动备份 + 自动清理:

# 每天凌晨2点备份,保留最近14天
0 2 * * * node ~/.openclaw/workspace/skills/openclaw-backup/scripts/backup.js --full --retain 14

通过 OpenClaw 的 cron 功能添加此任务后,系统会自动在每天凌晨执行备份,并只保留最近14天的备份文件。

输出文件

备份完成后会生成以下文件:

文件类型 文件名格式 说明
备份包 openclaw-backup-{type}-{YYYYMMDD}-{HHMMSS}.tar.gz 压缩备份文件
清单文件 openclaw-backup-{type}-{YYYYMMDD}-{HHMMSS}.json 备份清单(JSON格式)
恢复指南 RECOVERY_GUIDE.md 手动恢复操作指南

默认输出目录: ~/backups/openclaw/

重要说明

安全性

  • 不自动恢复: 本技能只提供备份功能,恢复需要根据生成的 RECOVERY_GUIDE.md 手动操作
  • 敏感文件保护: .env 文件会在清单中标记为敏感
  • 权限保持: 备份文件权限设为仅当前用户可读

文件处理

  • 不存在的文件会被跳过,在清单中标记为 "skipped"
  • 备份过程中不会修改原始文件
  • 临时文件会在备份完成后自动清理

依赖

  • Node.js >= 18.0.0
  • fs-extra (文件操作)
  • tar (压缩)
  • commander (命令行解析)
  • dayjs (日期处理)

安装

cd ~/.openclaw/workspace/skills/openclaw-backup
npm install  # 安装必要的依赖包(根据你的环境自动安装缺失的依赖)

注意事项

  1. 备份前确保有足够的磁盘空间
  2. 建议定期备份(可通过 cron 设置)
  3. 重要修改后建议立即备份
  4. 备份文件包含敏感信息,请妥善保管
  5. 恢复时请仔细阅读恢复指导书

相关文档

安全使用建议
This skill is coherent for backing up OpenClaw files and does not request external credentials. Before installing: 1) Review and run the script in dry-run mode to see what it will include; 2) remember backups will contain .env and other secrets — store backup files securely (encrypt them or use secure storage); 3) if you enable notifications or encryption in config, ensure any webhook tokens or keys are provided securely (the skill does not declare required env vars for those); 4) test restore in a safe environment before relying on automated restores; 5) note a functional inconsistency: the cleanup routine appears to look for backup directories named openclaw-backup-*, while backups are described as tar.gz files — confirm cleanup behavior on your system to avoid leaving old tar.gz files or accidentally deleting unexpected directories. If you want extra assurance, have someone you trust review scripts/backup.js and run with --dry-run and limited output-dir first.
功能分析
Type: OpenClaw Skill Name: oc-backup Version: 1.1.0 The oc-backup skill is a legitimate utility designed to archive OpenClaw configuration files, workspace data, and custom skills. The core logic in `scripts/backup.js` uses standard Node.js libraries (fs-extra, tar) to perform file collection, compression, and maintenance of a backup retention policy. The skill transparently handles sensitive files like `.env` as part of the backup process and provides comprehensive documentation, including a recovery guide template. No evidence of data exfiltration, malicious command execution, or harmful prompt injection was found.
能力评估
Purpose & Capability
The name/description (OpenClaw backup) aligns with the code and SKILL.md: the script collects files from ~/.openclaw (openclaw.json, .env, workspace, skills, cron, devices, memory) and produces tar.gz backup packages and manifests. No unrelated services, cloud APIs, or extraneous credentials are requested.
Instruction Scope
Instructions are focused on creating backups, using node scripts and optional cron scheduling. They explicitly reference backing up .env (marked sensitive) and other core files. The skill does read and package sensitive local files (.env with API keys) — this is expected for a backup tool but is important to note because backups will contain secrets. The SKILL.md does not instruct any network transmissions or access to unrelated system paths.
Install Mechanism
No automated remote install downloads are included in the registry metadata — it's an instruction+script package. Dependencies are standard npm modules (commander, fs-extra, tar, dayjs) declared in package.json; SKILL.md suggests running npm install locally. No obscure external URLs or archive-extract installs are used.
Credentials
The skill requests no environment variables or credentials and does not require additional secrets to run. However, it will back up the user's .env file (which contains API keys), so the resulting backups contain sensitive credentials. The config examples mention notification channels and an optional encryptionKey, but no credentials or webhooks are required by default — enabling notifications would likely require additional configuration (not declared as required here).
Persistence & Privilege
always is false and the skill does not request permanent system-level privileges. It does file-system operations confined to the ~/.openclaw area and the configured output directory. The script can delete old backups from the backup output directory (clean operation), which is expected behavior for a backup tool.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install oc-backup
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /oc-backup 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
OpenClaw 关键文件备份,支持备份保留策略和自动清理旧备份
元数据
Slug oc-backup
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

OC Backup 是什么?

备份 OpenClaw 关键配置文件、核心数据和自定义技能,支持全量及分类备份,自动管理备份文件保留和清理。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 107 次。

如何安装 OC Backup?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install oc-backup」即可一键安装,无需额外配置。

OC Backup 是免费的吗?

是的,OC Backup 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

OC Backup 支持哪些平台?

OC Backup 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 OC Backup?

由 FrankMei(@neverland83)开发并维护,当前版本 v1.1.0。

💬 留言讨论