OpenClaw Backup, Restore, and Migration: The Complete Guide
|6 min read
Table of Contents
Haven't installed OpenClaw yet?
curl -fsSL https://openclaw.ai/install.sh | bash
iwr -useb https://openclaw.ai/install.ps1 | iex
curl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Worried it'll affect your machine? ClawTank — cloud deploy in 60s, zero risk to your files.
OpenClaw Backup, Restore, and Migration: The Complete Guide
Your OpenClaw instance accumulates valuable state over time -- conversation memory, custom skills, integration configurations, API keys, and messaging session data. Losing this means rebuilding from scratch: re-pairing Telegram bots, re-creating skills, and losing all the context your agent has built up.
This guide covers backing up your data, restoring after failure, and migrating between servers.
What Data Needs Backing Up
Everything lives under ~/.openclaw/:
~/.openclaw/
openclaw.json # Main configuration
gateway.db # SQLite database (memory, conversations, state)
credentials/ # API keys and integration tokens
workspace/skills/ # Custom skills
workspace/memory/ # Persistent memory files
sessions/ # Telegram/WhatsApp session state
Component
Loss Impact
openclaw.json
Must reconfigure from scratch
gateway.db
Lose all accumulated context and history
credentials/
Must re-authenticate everything
workspace/skills/
Must rewrite custom skills
sessions/
Must re-pair messaging integrations
The most painful losses are gateway.db (weeks of conversation memory) and sessions/ (WhatsApp re-pairing is especially tedious[1]).
For Docker installations, data lives in a Docker volume with the same internal structure.
For partial restores, extract to /tmp and copy only what you need -- skills, the database, or credentials individually.
Server-to-Server Migration
1. Prepare the new server
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
npm install -g openclaw
# Do NOT run openclaw onboard -- we will restore over it
2. Backup and transfer
# On OLD server
sudo systemctl stop openclaw
tar -czf ~/openclaw-migration.tar.gz -C ~ .openclaw/
scp ~/openclaw-migration.tar.gz user@new-server:~/
3. Restore and configure
# On NEW server
tar -xzf ~/openclaw-migration.tar.gz -C ~
sqlite3 ~/.openclaw/gateway.db "PRAGMA integrity_check;"
Update ~/.openclaw/openclaw.json if the server has a different IP, hostname, or port. Then set up systemd and start the gateway.
4. Verify
openclaw status
openclaw chat "Are you working?"
openclaw integrations status
Keep the old server's backup for at least a week before decommissioning.
Messaging Session Migration
Telegram: Bot sessions transfer cleanly -- the bot token in credentials/telegram.json is all that is needed. You may need to re-approve devices with openclaw devices approve <id>.
WhatsApp: Session data in sessions/whatsapp/ contains cryptographic keys. It often migrates successfully, but if not, you will need to re-pair by scanning a QR code. Group memberships and chat history are preserved on the WhatsApp side[4]. Note down your groups before migrating.
# Export (self-hosted to ClawTank)
openclaw export --format clawtank -o ~/openclaw-export.zip
# Import (ClawTank to self-hosted)
openclaw import ~/clawtank-export.zip
API keys are excluded from exports for security -- re-enter them after import.
Backup Strategy Recommendations
Minimum: Daily local cron backups with 30-day retention.
Recommended: Daily local backups + weekly cloud backups to S3 or B2 (90-day retention) + pre-change backups before upgrades + monthly restore tests.
Production: Hourly local backups + daily cloud backups to two providers (1-year retention) + automated monitoring that alerts when backups stop.
Common Issues
Database locked during backup: Use sqlite3 ... ".backup" instead of copying the file directly.
Corrupt archive: If tar -tzf fails, try partial extraction with 2>/dev/null || true.
Messaging fails after restore: Ensure the system clock is accurate (sudo timedatectl set-ntp true). Session tokens include timestamps.
Permission errors: Fix ownership with sudo chown -R your-user:your-user ~/.openclaw/ and set chmod 600 ~/.openclaw/credentials/*.
Summary
A solid backup strategy takes 30 minutes to set up and protects months of accumulated agent state. The essential steps: automate daily backups, add cloud redundancy, test your restores, and use the same backup/restore process for server migrations. Do not wait for a failure to discover your backups do not work.