Skill: richardx0319/openclaw-backup-pro (version 1.1.0)

--- name: openclaw-backup description: Backup and restore OpenClaw data. Use when user asks to create backups, set up automatic backup schedules, restore from backup, or manage backup rotation. Handles ~/.openclaw directory archiving with proper exclusions. --- # OpenClaw Backup Backup and restore OpenClaw configuration, credentials, and workspace. ## Create Backup Run the backup script: ```bash ./scripts/backup.sh [backup_dir] ``` Default backup location: `~/openclaw-backups/` Output: `openclaw-YYYY-MM-DD_HHMM.tar.gz` ## What Gets Backed Up - `openclaw.json` — main config - `credentials/` — API keys, tokens - `agents/` — agent configs, auth profiles - `workspace/` — memory, SOUL.md, user files - `telegram/` — session data - `cron/` — scheduled tasks ## Excluded - `completions/` — cache, regenerated automatically - `*.log` — logs ## Setup Daily Backup with Cron Use OpenClaw cron for daily backups with notification: ```json { "name": "daily-backup", "schedule": {"kind": "cron", "expr": "0 3 * * *", "tz": "UTC"}, "payload": { "kind": "agentTurn", "message": "Run ~/.openclaw/backup.sh and report result to user." }, "sessionTarget": "isolated", "delivery": {"mode": "announce"} } ``` ## Restore See [references/restore.md](references/restore.md) for step-by-step restore instructions. Quick restore: ```bash openclaw gateway stop mv ~/.openclaw ~/.openclaw-old tar -xzf ~/openclaw-backups/openclaw-YYYY-MM-DD_HHMM.tar.gz -C ~ openclaw gateway start ``` ## Rotation Script keeps last 7 backups automatically.

path: _meta.json
content: ownerId: kn767bpva5fcrrd9hhxcjnfnns80pzhp
slug: openclaw-backup-restore
version: 1.1.0
publishedAt: 1770475997563

path: references/restore.md
content: # Restore OpenClaw from Backup

## Quick Restore

```bash
# 1. Stop OpenClaw
openclaw gateway stop

# 2. Backup current (safety)
mv ~/.openclaw ~/.openclaw-old

# 3. Extract backup
cd ~
tar -xzf ~/openclaw-backups/openclaw-YYYY-MM-DD_HHMM.tar.gz

# 4. Start OpenClaw
openclaw gateway start

# 5. Verify
openclaw status
```

## Rollback if Restore Fails

```bash
rm -rf ~/.openclaw
mv ~/.openclaw-old ~/.openclaw
openclaw gateway start
```

## What's in a Backup

```
~/.openclaw/
├── openclaw.json      # Main config
├── credentials/       # API keys, tokens
├── agents/            # Agent configs, auth
├── workspace/         # Memory, SOUL.md, files
├── telegram/          # Telegram session
└── cron/              # Scheduled tasks
```

## Excluded from Backup

- `completions/` — API response cache (regenerated)
- `*.log` — Log files


path: scripts/backup.sh
content: #!/bin/bash
# OpenClaw Backup Script
# Usage: ./backup.sh [backup_dir]

BACKUP_DIR="${1:-$HOME/openclaw-backups}"
DATE=$(date +%Y-%m-%d_%H%M)
BACKUP_FILE="$BACKUP_DIR/openclaw-$DATE.tar.gz"

mkdir -p "$BACKUP_DIR"

# Create backup (exclude completions cache and logs)
tar -czf "$BACKUP_FILE" \
    --exclude='completions' \
    --exclude='*.log' \
    -C "$HOME" .openclaw/ 2>/dev/null

if [ $? -eq 0 ]; then
    SIZE=$(du -h "$BACKUP_FILE" | cut -f1)
    
    # Rotate: keep only last 7 backups
    ls -t "$BACKUP_DIR"/openclaw-*.tar.gz 2>/dev/null | tail -n +8 | xargs -r rm
    
    COUNT=$(ls "$BACKUP_DIR"/openclaw-*.tar.gz 2>/dev/null | wc -l)
    
    echo "✅ Backup created: $BACKUP_FILE ($SIZE)"
    echo "📁 Total backups: $COUNT"
    exit 0
else
    echo "❌ Backup failed"
    exit 1
fi


path: scripts/restore.sh
content: #!/bin/bash
# OpenClaw Restore Script
# Usage: ./restore.sh [backup_file]
# If no backup file specified, restores the latest backup

BACKUP_DIR="${HOME}/openclaw-backups"
LATEST_BACKUP=$(ls -t "$BACKUP_DIR"/openclaw-*.tar.gz 2>/dev/null | head -1)
BACKUP_FILE="${1:-$LATEST_BACKUP}"

if [ -z "$BACKUP_FILE" ]; then
    echo "❌ No backup found in $BACKUP_DIR"
    exit 1
fi

if [ ! -f "$BACKUP_FILE" ]; then
    echo "❌ Backup file not found: $BACKUP_FILE"
    exit 1
fi

echo "📦 Restoring from: $BACKUP_FILE"

# Stop gateway
echo "🛑 Stopping gateway..."
openclaw gateway stop

# Backup current state
if [ -d "$HOME/.openclaw" ]; then
    mv "$HOME/.openclaw" "$HOME/.openclaw-pre-restore-$(date +%Y%m%d_%H%M)"
    echo "✅ Current state backed up to ~/.openclaw-pre-restore-*"
fi

# Extract backup
tar -xzf "$BACKUP_FILE" -C "$HOME"

if [ $? -eq 0 ]; then
    echo "✅ Restore completed successfully"
    
    # Restart gateway
    echo "🔄 Starting gateway..."
    openclaw gateway start
    
    echo "✅ Gateway restarted"
    exit 0
else
    echo "❌ Restore failed"
    echo "💡 You can restore from: $HOME/.openclaw-pre-restore-*"
    exit 1
fi


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)