{"skill":{"slug":"backupclaw","displayName":"backup claw","summary":"Backup and restore OpenClaw configuration files. Use when the user wants to backup ~/.openclaw/ configuration (excluding workspace) to a date-stamped directo...","description":"---\nname: backupclaw\ndescription: Backup and restore OpenClaw configuration files. Use when the user wants to backup ~/.openclaw/ configuration (excluding workspace) to a date-stamped directory, or restore from a previous backup. Includes backup with diff-based change detection and changelog logging, and restore by date. The backup directory path ($backup_claw_dir) must be obtained from the user before first use.\n---\n\n# Backupclaw\n\n## Overview\n\nFull backup and restore capability for OpenClaw configuration files. Backups are stored in date-stamped directories (YYYY-MM-DD format). Only performs backup when configuration has actually changed.\n\n## Core Operations\n\n### 0. Backup Directory Management (NEW)\n\n**Configuration file:**\n- Location: `~/.openclaw/backup.json`\n- Format:\n  ```json\n  {\n    \"backup_location\": \"/path/to/backup/directory\"\n  }\n  ```\n\n**Get backup directory:**\n1. Check if `~/.openclaw/backup.json` exists\n2. If exists, read \"backup_location\" field\n3. If missing or file doesn't exist:\n   - Ask user for backup directory path\n   - Create `~/.openclaw/backup.json` with the provided path\n   - Confirm path to user\n\n**Change backup directory (changedir command):**\nWhen user runs `backupclaw changedir <new_path>`:\n1. Validate new path exists and is writable\n2. Update `~/.openclaw/backup.json` with new path\n3. Inform user of successful change\n\n**Example changedir usage:**\n- \"backupclaw changedir ~/backups/openclaw\"\n- \"修改备份目录到 /mnt/backup/openclaw\"\n\n### 1. Backup Configuration\n\n**Backup directory setup:**\n- Get backup directory using the management flow above (Section 0)\n- No longer store in TOOLS.md; use backup.json instead\n\n**Backup process:**\n1. Generate current date string in YYYY-MM-DD format\n2. If backup directory has no previous backups:\n   - Copy all files from `~/.openclaw/` to `$backup_claw_dir/YYYY-MM-DD/`, excluding `workspace/`\n   - Record initial backup in changelog\n3. If previous backups exist:\n   - Find the most recent backup directory (latest date)\n   - Compare files between latest backup and current `~/.openclaw/` using `diff`\n   - If no changes detected: Tell user \"配置文件没有变化，不需要备份\"\n   - If changes detected:\n     - Create new date-stamped directory\n     - Copy all files from `~/.openclaw/` to new directory, excluding `workspace/`\n     - Update changelog with list of modified files\n     - Report changes to user\n\n**Changelog format:**\n- Located at `$backup_claw_dir/changelog.md`\n- Each entry includes date, time, and list of changed files\n- Format example:\n  ```markdown\n  ## 2026-03-12 14:30:00\n  - openclaw.json (modified)\n  - extensions/feishu/skills/feishu-doc/SKILL.md (added)\n  ```\n\n**Exclusion rules:**\n- Always exclude `workspace/` directory from backup\n- Preserve directory structure for all other files\n\n### 2. Restore Configuration\n\n**Restore process:**\n1. Accept date parameter in YYYY-MM-DD format\n2. Verify backup directory exists at `$backup_claw_dir/YYYY-MM-DD/`\n3. If backup not found, inform user and list available dates\n4. If backup found:\n   - Warn user about overwriting current configuration\n   - Confirm before proceeding\n   - Restore files from backup to `~/.openclaw/`\n   - Exclude `workspace/` from restoration\n   - Report success and list restored files\n\n## Usage Examples\n\n**Typical user requests that trigger this skill:**\n- \"backup my openclaw config\"\n- \"restore openclaw backup from 2026-03-12\"\n- \"check if config changed\"\n- \"备份 openclaw 配置\"\n- \"恢复 2026-03-12 的备份\"\n- \"backupclaw changedir ~/backups/openclaw\"\n- \"修改备份目录\" (prompts for new path)\n\n## Implementation Notes\n\n**Tools to use:**\n- `rsync` or `cp -r` for copying files\n- `diff` for comparing file contents\n- `find` with `sort` and `tail` to find latest backup\n- Date command: `date +%Y-%m-%d`\n- `read` and `write` tools for managing `~/.openclaw/backup.json`\n\n**Backup directory management:**\n- Always check `~/.openclaw/backup.json` first before asking user\n- Only prompt for backup path if backup_location is not set\n- Validate directory exists and is writable before saving\n- Use `write` tool to create/update backup.json\n\n**changedir command handling:**\n- Parse command format: `backupclaw changedir <path>` or equivalent Chinese phrasing\n- Validate new directory exists and is writable (create if doesn't exist, ask first)\n- Update backup.json with new path\n- Confirm successful change to user\n\n**Backup directory structure:**\n```\n$backup_claw_dir/\n├── 2026-03-12/\n│   ├── openclaw.json\n│   ├── agents/\n│   ├── extensions/\n│   └── ...\n├── 2026-03-13/\n│   └── ...\n└── changelog.md\n```\n\n**Error handling:**\n- Always verify backup directory exists and is writable before proceeding\n- Check for sufficient disk space\n- Validate date format for restore operation\n- Provide clear error messages in Chinese when appropriate\n","tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":526,"installsAllTime":0,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1773297269304,"updatedAt":1778491848315},"latestVersion":{"version":"1.0.0","createdAt":1773297269304,"changelog":"Initial release of backupclaw: backup and restore OpenClaw configuration files.\n\n- Backs up `~/.openclaw/` (excluding `workspace/`) to a user-specified, date-stamped directory, with diff-based change detection.\n- Manages backup directory via `~/.openclaw/backup.json`; prompts user if not set.\n- Allows backup directory change with the `backupclaw changedir <path>` command.\n- Maintains a changelog of changes in `changelog.md`.\n- Supports restoring configuration from any backup date.\n- Provides clear error handling and multilingual prompts.","license":"MIT-0"},"metadata":null,"owner":{"handle":"flyingtimes","userId":"s17a1crq2ecdvx8g934wzyh9yn83q44e","displayName":"flyingtimes","image":"https://avatars.githubusercontent.com/u/5668052?v=4"},"moderation":null}