SOUL Backup Skill
by @x-rayluan
Backup and restore OpenClaw workspace SOUL files with versioning, validation, and sanitized openclaw.json handling.
clawhub install soul-backup-skillπ About This Skill
name: soul-backup-skill description: Backup and restore OpenClaw workspace SOUL files with versioning, validation, and sanitized openclaw.json handling. homepage: https://github.com/X-RayLuan/soul-backup-skill
SOUL Backup Skill
Backup and restore OpenClaw workspace SOUL files (SOUL.md, USER.md, AGENTS.md, IDENTITY.md, TOOLS.md, HEARTBEAT.md, BOOTSTRAP.md) with versioning, validation, and rollback capabilities.
Purpose
Protect critical workspace configuration files from accidental deletion, corruption, or misconfiguration. Enable quick recovery and version history tracking.
What Gets Backed Up
Core SOUL files from workspace root:
SOUL.md β agent personality and missionUSER.md β user profile and preferencesAGENTS.md β agent instructions and workflowsIDENTITY.md β agent identity configurationTOOLS.md β local tool configurationHEARTBEAT.md β periodic task configurationBOOTSTRAP.md β initialization instructionsConfig backup policy:
openclaw.json is included via a sanitized copy: openclaw.sanitized.jsontoken, key, secret, password, etc.)Usage
Backup Current SOUL Files
# Create timestamped backup
node scripts/backup.mjsCreate named backup
node scripts/backup.mjs --name "pre-migration"Backup with description
node scripts/backup.mjs --desc "Before major refactor"
List Backups
# List all backups
node scripts/list.mjsShow detailed info
node scripts/list.mjs --verbose
Restore from Backup
# Restore latest backup
node scripts/restore.mjsRestore specific backup by timestamp
node scripts/restore.mjs --timestamp 2026-03-05T00-51-30Restore specific backup by name
node scripts/restore.mjs --name "pre-migration"Dry run (preview without applying)
node scripts/restore.mjs --dry-run
Validate Backup Integrity
# Validate all backups
node scripts/validate.mjsValidate specific backup
node scripts/validate.mjs --timestamp 2026-03-05T00-51-30
Backup Structure
backups/
βββ 2026-03-05T00-51-30/
β βββ manifest.json # Backup metadata
β βββ SOUL.md
β βββ USER.md
β βββ AGENTS.md
β βββ IDENTITY.md
β βββ TOOLS.md
β βββ HEARTBEAT.md
β βββ BOOTSTRAP.md
βββ 2026-03-05T01-15-42/
β βββ ...
βββ named/
βββ pre-migration/
β βββ ...
βββ stable-v1/
βββ ...
Manifest Format
Each backup includes a manifest.json:
{
"timestamp": "2026-03-05T00:51:30.123Z",
"name": "pre-migration",
"description": "Before major refactor",
"workspace": "/Users/m1/.openclaw/workspace-hunter",
"files": {
"SOUL.md": {
"size": 1234,
"hash": "sha256:abc123...",
"exists": true
},
"USER.md": {
"size": 567,
"hash": "sha256:def456...",
"exists": true
}
},
"created_by": "hunter",
"openclaw_version": "1.0.0"
}
Recovery Workflow
Standard Recovery
1. List available backups: node scripts/list.mjs
2. Preview restore: node scripts/restore.mjs --timestamp
3. Apply restore: node scripts/restore.mjs --timestamp
4. Verify: Check workspace files manually
Emergency Recovery
If workspace is corrupted and scripts won't run:
# Manual restore from backup directory
cd /Users/m1/.openclaw/workspace-hunter
cp -r soul-backup-skill/backups/LATEST_TIMESTAMP/* .
Rollback After Bad Restore
Every restore creates an automatic pre-restore backup:
# Restore creates: backups/pre-restore-2026-03-05T01-20-00/
To rollback:
node scripts/restore.mjs --timestamp pre-restore-2026-03-05T01-20-00
Automation
Cron Schedule (Recommended)
Add to OpenClaw heartbeat or system cron:
# Daily backup at 2 AM
0 2 * * * cd /Users/m1/.openclaw/workspace-hunter/soul-backup-skill && node scripts/backup.mjs --name "daily-$(date +\%Y-\%m-\%d)"Weekly backup on Sunday
0 3 * * 0 cd /Users/m1/.openclaw/workspace-hunter/soul-backup-skill && node scripts/backup.mjs --name "weekly-$(date +\%Y-W\%V)"
Pre-Deployment Hook
# Before deploying changes
cd /Users/m1/.openclaw/workspace-hunter/soul-backup-skill
node scripts/backup.mjs --name "pre-deploy-$(git rev-parse --short HEAD)"
Validation Checks
The validate script checks:
Failure Scenarios & Recovery
Scenario 1: Accidental SOUL.md Deletion
# Immediate recovery
node scripts/restore.mjs --file SOUL.mdOr full restore
node scripts/restore.mjs
Scenario 2: Bad Configuration Change
# Preview what will be restored
node scripts/restore.mjs --dry-runRestore previous version
node scripts/restore.mjs --timestamp
Scenario 3: Corrupted Backup
# Validate all backups
node scripts/validate.mjsFind last good backup
node scripts/list.mjs --verboseRestore from last good backup
node scripts/restore.mjs --timestamp
Scenario 4: Complete Workspace Loss
# Recreate workspace directory
mkdir -p /Users/m1/.openclaw/workspace-hunterClone backup skill
cd /Users/m1/.openclaw/workspace-hunter
git clone soul-backup-skillRestore latest backup
cd soul-backup-skill
node scripts/restore.mjs
Best Practices
1. Backup before major changes: Always create a named backup before refactoring SOUL files
2. Validate regularly: Run validate.mjs weekly to catch corruption early
3. Keep 30 days of backups: Prune old backups monthly
4. Test restore process: Practice recovery quarterly
5. Document custom changes: Use --desc flag to explain why backup was created
6. Version control: Consider committing backup directory to git for off-machine redundancy
Security Notes
Dependencies
Troubleshooting
"Backup directory not found"
mkdir -p backups in skill directory"Permission denied"
ls -la ..chmod +x scripts/*.mjs"Hash mismatch during validation"
"Restore failed: file conflicts"
--force flag to overwrite existing filesFuture Enhancements
π‘ Examples
Backup Current SOUL Files
# Create timestamped backup
node scripts/backup.mjsCreate named backup
node scripts/backup.mjs --name "pre-migration"Backup with description
node scripts/backup.mjs --desc "Before major refactor"
List Backups
# List all backups
node scripts/list.mjsShow detailed info
node scripts/list.mjs --verbose
Restore from Backup
# Restore latest backup
node scripts/restore.mjsRestore specific backup by timestamp
node scripts/restore.mjs --timestamp 2026-03-05T00-51-30Restore specific backup by name
node scripts/restore.mjs --name "pre-migration"Dry run (preview without applying)
node scripts/restore.mjs --dry-run
Validate Backup Integrity
# Validate all backups
node scripts/validate.mjsValidate specific backup
node scripts/validate.mjs --timestamp 2026-03-05T00-51-30
π Tips & Best Practices
1. Backup before major changes: Always create a named backup before refactoring SOUL files
2. Validate regularly: Run validate.mjs weekly to catch corruption early
3. Keep 30 days of backups: Prune old backups monthly
4. Test restore process: Practice recovery quarterly
5. Document custom changes: Use --desc flag to explain why backup was created
6. Version control: Consider committing backup directory to git for off-machine redundancy