| name | safe-backup |
| description | Backup OpenClaw state directory and workspace. Includes excluding sensitive files, packaging for backup. Triggered when user asks to backup, export, or save state. |
Safe Backup
Backup OpenClaw state directory and workspace with security best practices.
⚠️ Security Warnings
- Backup may contain sensitive data - review before sharing
- If uploading to GitHub - use a private repository and consider encryption
- auth-profiles.json is EXCLUDED - after restore, you must re-authenticate
- This script does NOT automatically push to any remote
Quick Start
1. Run Backup
~/.openclaw/skills/safe-backup/scripts/backup.sh
2. Check Output
Backup file: /tmp/safe-backup-20260223.tar.gz
3. Store Securely
See "Storage Options" below.
What Gets Backed Up
✅ Included (Safe to Backup)
| Directory | Contents |
|---|
~/.openclaw/ | OpenClaw configuration |
~/.openclaw/workspace/ | Agent workspace files |
agents/ | Agent definitions |
skills/ | Installed skills |
memory/ | Memory files |
hooks/ | Custom hooks |
❌ Excluded (Sensitive - Not Backed Up)
| Pattern | Reason |
|---|
*.log | Log files |
sessions.json | Session data |
auth-profiles.json | API tokens & credentials |
.env | Environment variables |
*.pem, *.key | TLS/SSH keys |
credentials.json | Stored credentials |
api-keys.json | API keys |
Complete Workflow
Phase 1: Backup
~/.openclaw/skills/safe-backup/scripts/backup.sh
tar -tzf /tmp/safe-backup-20260223.tar.gz | less
Phase 2: Storage
Choose one:
Option A: Local Encrypted Storage (Recommended)
openssl enc -aes-256-cbc -salt -in /tmp/safe-backup-20260223.tar.gz -out ~/backups/safe-backup-20260223.tar.gz.enc
rm /tmp/safe-backup-20260223.tar.gz
Option B: Private GitHub Repository
git clone https://github.com/YOUR_USERNAME/safe-backup.git ~/safe-backup
mkdir -p ~/safe-backup/2026-02-23
tar -xzf /tmp/safe-backup-20260223.tar.gz -C ~/safe-backup/2026-02-23/
cd ~/safe-backup
git add .
git commit -m "Backup 2026-02-23"
git push origin main
rm -rf ~/safe-backup
rm /tmp/safe-backup-20260223.tar.gz
Option C: rsync to Remote Server
rsync -avz --delete \
--exclude='*.log' \
--exclude='sessions.json' \
~/.openclaw/ user@backup-server:/path/to/backups/
Phase 3: Restore
Step 1: Locate Backup
openssl enc -aes-256-cbc -d -in ~/backups/safe-backup-20260223.tar.gz.enc -out /tmp/safe-backup.tar.gz
cp /path/to/safe-backup-20260223.tar.gz /tmp/
Step 2: Stop Gateway
systemctl --user stop openclaw-gateway
Step 3: Restore Files
mkdir -p /tmp/restore
tar -xzf /tmp/safe-backup.tar.gz -C /tmp/restore
cp -r /tmp/restore/state/* ~/.openclaw/
cp -r /tmp/restore/workspace/* ~/.openclaw/workspace/
Step 4: Re-authenticate
Because auth-profiles.json was excluded, you must re-configure:
openclaw config edit
nano ~/.openclaw/agents/main/agent/auth-profiles.json
Required re-configuration:
- Telegram bot token
- Discord bot token
- Feishu credentials
- Any other API keys
Step 5: Restart Gateway
systemctl --user start openclaw-gateway
openclaw status
Environment Variables
| Variable | Default | Description |
|---|
OPENCLAW_STATE_DIR | $HOME/.openclaw | OpenClaw state directory |
OPENCLAW_WORKSPACE_DIR | $HOME/.openclaw/workspace | Workspace directory |
Example:
OPENCLAW_STATE_DIR=/data/openclaw ~/.openclaw/skills/safe-backup/scripts/backup.sh
Troubleshooting
"State directory not found"
ls -la ~/.openclaw
"Permission denied"
chmod +x ~/.openclaw/skills/safe-backup/scripts/backup.sh
Restore Fails
tar -tzf /tmp/safe-backup.tar.gz
openssl enc -aes-256-cbc -d -in backup.enc -o /dev/null
Best Practices
- Backup regularly - at least weekly
- Test restore - periodically verify backups work
- Store offsite - keep backup in different location
- Encrypt - never store unencrypted backups in cloud
- Document - keep notes on what was re-configured after restore