You've spent hours configuring your OpenClaw agent — custom skills, channel integrations, fine-tuned prompts, conversation history. Now imagine losing all of it to a disk failure or a botched update. Backups aren't optional. This tutorial walks you through a practical backup and recovery strategy for your OpenClaw deployment on Tencent Cloud Lighthouse.
Before setting up any backup process, let's identify what actually matters in an OpenClaw deployment:
.env files containing secrets and API credentials.Follow the classic 3-2-1 backup rule:
For a Lighthouse-hosted OpenClaw instance, this translates to:
Tencent Cloud Lighthouse includes a built-in snapshot feature that captures your entire server state — OS, applications, configurations, and data.
Creating a snapshot:
openclaw-backup-2025-03-05.Pros: Captures everything, one-click restore, no configuration needed.
Cons: Snapshot storage has limits on free tier; restoring means reverting the entire server.
Recommendation: Create a snapshot before every major change — skill installations, OpenClaw version upgrades, or configuration overhauls.
For more granular control, set up automated file-level backups using a simple shell script.
#!/bin/bash
# openclaw-backup.sh
BACKUP_DIR="/opt/backups/openclaw"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="${BACKUP_DIR}/openclaw_backup_${TIMESTAMP}.tar.gz"
# Create backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
# Define what to back up (adjust paths to your installation)
tar -czf "$BACKUP_FILE" \
/opt/openclaw/config/ \
/opt/openclaw/.env \
/opt/openclaw/skills/ \
/opt/openclaw/data/ \
/opt/openclaw/logs/ \
2>/dev/null
# Keep only last 7 daily backups
find "$BACKUP_DIR" -name "openclaw_backup_*.tar.gz" -mtime +7 -delete
echo "Backup created: $BACKUP_FILE"
echo "Size: $(du -h "$BACKUP_FILE" | cut -f1)"
chmod +x /opt/scripts/openclaw-backup.sh
# Add to crontab - runs daily at 3 AM
crontab -e
# Add this line:
0 3 * * * /opt/scripts/openclaw-backup.sh >> /var/log/openclaw-backup.log 2>&1
# Check the backup log
tail -20 /var/log/openclaw-backup.log
# List recent backups
ls -lh /opt/backups/openclaw/
For true disaster recovery, copy backups offsite. You can use Tencent Cloud's COS (Cloud Object Storage) or any S3-compatible service.
#!/bin/bash
# offsite-backup.sh — runs after the local backup
LATEST_BACKUP=$(ls -t /opt/backups/openclaw/openclaw_backup_*.tar.gz | head -1)
# Upload to COS using coscli
coscli cp "$LATEST_BACKUP" cos://your-bucket-name/openclaw-backups/
echo "Offsite backup uploaded: $LATEST_BACKUP"
This is the nuclear option — it restores your entire server to the snapshot state.
When to use: Catastrophic failures, corrupted OS, or when you need to roll back everything.
For targeted recovery (e.g., you accidentally deleted a skill configuration):
# Extract specific files from a backup
tar -xzf /opt/backups/openclaw/openclaw_backup_20250305_030000.tar.gz \
-C / \
opt/openclaw/skills/my-custom-skill/
# Restart OpenClaw to pick up the restored files
sudo systemctl restart openclaw
If you need to migrate to a new Lighthouse instance (perhaps upgrading to a larger spec from the Tencent Cloud Lighthouse Special Offer):
scp /opt/backups/openclaw/openclaw_backup_latest.tar.gz user@new-server:/tmp/
tar -xzf /tmp/openclaw_backup_latest.tar.gz -C /
A backup you've never tested is not a backup — it's a hope. Schedule quarterly recovery tests:
Setting up backups takes 30 minutes. Rebuilding a fully configured OpenClaw instance from memory takes days — if you can even remember all the configurations. Invest the 30 minutes. Future you will be grateful.