How do you back up an OpenClaw host with openclaw backup and move it to a new machine, and what does a restore not bring back cleanly?
answer
- stop first, then archive
- restore never touches live state
- activation is a separate offline step
- restoring is time travel
basics
~20 sStop the Gateway, run openclaw backup create --verify, restore the archive on the new host into an empty staging directory, move it into place offline and run openclaw doctor. Ratcheting channel logins such as WhatsApp, approvals and plugin packages may need attention.
solid answer
~40 sEverything that matters lives in the state directory (`~/.openclaw`, or `OPENCLAW_STATE_DIR`) plus the workspace. On the old host, `openclaw gateway stop`, then `openclaw backup create --output <dir> --verify`; the archive holds config and its `$include` files, auth stores, channel state, sessions and, by default, workspaces. On the new host, `openclaw backup restore <archive> --target <empty-dir>` verifies and extracts to staging. It never restores in place and has no `--force`. With the Gateway stopped, move the assets to the locations in `manifest.json` or point `OPENCLAW_STATE_DIR` at them, then `openclaw doctor` and restart. Restoring is time travel: WhatsApp's ratcheting credentials may need relinking, approvals and delivery state roll back, and plugin `node_modules` must be reinstalled. The archive contains credentials, so store it accordingly.
code
bash · 10 lines# old host
openclaw gateway stop
openclaw backup create --output ~/Backups/openclaw --verify
# new host, after copying the archive
openclaw backup restore ~/Backups/openclaw/<archive>.tar.gz --target ~/openclaw-restored
# move assets per manifest.json, or set OPENCLAW_STATE_DIR, then:
openclaw doctor
openclaw gateway restart
openclaw statusgo deeper
Recall that the state directory and workspace are what you back up, and that openclaw backup create makes the archive.
Explain the stop, create with verify, restore to staging, activate and Doctor sequence, and why restore never writes in place.
Anticipate what rolls back badly, from ratcheting channel logins and pending approvals to plugin packages and symlinks, and handle the archive as a credential.
Set a backup routine and a restore drill for the assistant, deciding which state is worth versioning and where its credential-bearing archives may live.
## What you are actually moving A Gateway's identity is its **state directory**, `~/.openclaw` by default (or whatever `OPENCLAW_STATE_DIR` points at), plus its workspace, `~/.openclaw/workspace` by default. Together they hold: - **Config:** `openclaw.json` and any `$include` files it pulls in. - **Auth:** the shared and per-agent SQLite auth stores with API keys and OAuth tokens. - **Channel state:** the WhatsApp login, Telegram session and similar. - **Sessions:** conversation history and agent state. - **Workspace files:** memory, skills and prompts. The install itself (the npm package, the service unit) is cheap to recreate. Back up the state, not the binary. ## Find the right directory first Run `openclaw status` on the old machine to confirm which state directory the install uses. Custom profiles live in `~/.openclaw-<profile>/` or wherever `OPENCLAW_STATE_DIR` points, and a host with several profiles needs one backup per profile, run with that profile selected. A frequent surprise on the new host is a channel that stops answering because its token came from the environment: if Telegram or Discord relies on the `TELEGRAM_BOT_TOKEN` or `DISCORD_BOT_TOKEN` fallback, check that the migrated state-directory `.env` carries those keys, without printing their values. ## Making the archive ```bash openclaw gateway stop openclaw backup create --output ~/Backups/openclaw --verify ``` - **Stop first.** A raw copy of a changing SQLite database can capture mismatched database and WAL files. `openclaw backup create` takes consistent per-database snapshots, but it is not one atomic snapshot across config and every database, so for a machine move the docs say to quiesce the Gateway. - **Default contents:** config with its `$include` dependencies, auth profiles, channel and provider credentials, sessions and, unless you pass `--no-include-workspace`, the workspaces. - **`--verify`** checks the archive right after writing it: one root manifest, no traversal paths, every declared payload present, and valid SQLite snapshots. - **`--only-config`** exports the root config file alone, not its includes. It is not a recovery point. - Existing archives are never overwritten, and an output path inside the backed-up tree is rejected. For routine protection, `openclaw backup enable` schedules versioned Git dumps of the SQLite databases to a private repository. They cover the databases only, so config and workspaces still need a file archive. ## Restoring on the new host 1. Install OpenClaw on the new machine; a fresh `~/.openclaw` from onboarding is fine, because you replace it. 2. Copy the archive over a protected channel and run `openclaw backup restore <archive.tar.gz> --target ~/openclaw-restored`. The target must be empty or absent and outside the live state. Restore verifies before writing and removes a partial extraction on failure. 3. With the Gateway stopped, move the restored assets to the paths recorded in `manifest.json`, or point `OPENCLAW_STATE_DIR` at the restored state. Make sure the files belong to the user who runs the Gateway. 4. Review absolute symbolic links, which keep their original targets. 5. Run `openclaw doctor` to apply config migrations and repair the service, then `openclaw gateway restart` and `openclaw status`. ## What does not come back cleanly | Item | Why | What to do | | --- | --- | --- | | WhatsApp and other ratcheting logins | Older credential state can fall out of sync | Expect to relink the channel | | Approvals, delivery and dedupe state | They roll back with the archive | Review pending approvals before resuming | | Plugin `node_modules` | Not archived | `openclaw plugins update <id>` or reinstall | | The `plugin-skills/` link index | Not archived | `openclaw skills list` rebuilds it | Also keep the old Gateway stopped once the new one is live, so the same channel accounts are not driven from two hosts. ## Treat the archive as a secret Current OAuth access and refresh tokens are stored in plaintext SQLite rows in the state directory, and full archives also copy included config files that may hold sensitive values. An archive left in a shared folder exposes the assistant's provider and channel credentials just as the live directory would.
- Why does openclaw backup restore refuse to write into the live state directory?Restoring is time travel, and an in-place overwrite would mix old and current files with no way back. The command verifies the archive and extracts into an empty staging directory only. Activation is a separate offline step: you stop the Gateway, move or point at the restored assets, and let `openclaw doctor` check them before restarting.
- Is the archive enough to rebuild the host after a disk failure?It covers state, credentials, sessions and, by default, workspaces, which is what you cannot recreate. You still reinstall OpenClaw and its service, reinstall plugin packages, may relink WhatsApp, and fix absolute symbolic links that pointed at paths on the old disk.
- Copying ~/.openclaw while the Gateway runs is as good as a backup.
- openclaw backup restore overwrites the live state when given --force.
- --only-config is a complete recovery point for a modular config.
- A restored WhatsApp login always resumes without relinking.
- Backup archives hold no secrets, so any shared folder will do.