You moved OpenClaw to a new Mac, a faster mini PC, or a VPS. You installed the CLI, copied your folder across, started the gateway, and messaged your agent. Then it answers like a stranger: “I don’t have any context on that.”
Or the symptoms stack up in a different order. Telegram asks you to log in again. Discord goes quiet. Your scheduled jobs never fire. Your MEMORY.md is sitting right there on disk, but the agent acts like it has never met you. And in the worst version, both machines answer the same message, so you get two replies to everything and two versions of the truth.
This is the most common thing that goes wrong when an agent moves house, and it is almost never a bug. It is a copy problem. The agent’s memory is not in the file you copied. This guide is the exact sequence I use to move an agent between machines without losing sessions, channel logins, or a week of re-onboarding.
Why Your Agent Forgot Everything
OpenClaw keeps its state in one directory, ~/.openclaw/ by default. That directory holds four different kinds of data, and people usually copy one or two of them.
1. The config file is not the state. openclaw.json is just settings. Your model auth lives in state/openclaw.sqlite. Agent profiles live in agents/<agentId>/agent/openclaw-agent.sqlite. Channel and provider logins live under credentials/. Copy the JSON and you get a correctly configured agent with no memory and no accounts.
2. The profile or state-dir path changed. If the old gateway was launched with --profile or a custom OPENCLAW_STATE_DIR, and the new one starts with defaults, it reads an empty ~/.openclaw. Everything looks logged out and every session looks new, even though your real data is a few folders away.
3. The database was copied while running. SQLite writes through a WAL file. If you copy the live database and skip the -wal file, or copy both at different moments, you get a torn database. The gateway then fails a migration check or starts with partial history.
4. Both machines are still live. Two gateways, one bot token. Messages get answered twice, scheduled jobs run in two places, and each instance writes state the other one cannot see.
Confirm Which One You Have (5 Minutes)
Run these on both machines before you change anything. The answer tells you which fix below applies, and it stops you from “fixing” a healthy install.
- Compare state directories. On the old machine, run
openclaw statusand note the state directory path and profile it reports. Run the same command on the new machine. If the paths differ, you have cause 2 and you can skip straight to Fix 1. - Check what actually arrived. Run
ls -la ~/.openclawandls -la ~/.openclaw/credentials. Ifcredentials/is empty or missing, no channel login came across. - Check the token fallback. If your channels rely on env fallbacks, confirm the keys exist without printing them:
awk -F= '/^(TELEGRAM_BOT_TOKEN|DISCORD_BOT_TOKEN)=/ { print $1 "=present" }' ~/.openclaw/.env - Look for a second gateway. Run
lsof -i :18789andps aux | grep openclaw. If the old machine is still serving, you have cause 4. - Ask the doctor. Run
openclaw doctor. It flags a CLI or gateway state-directory mismatch and missing channel tokens directly, which saves you guessing.
One note on a wrong turn most people take first: openclaw migrate is for importing from another agent system such as Claude or Hermes. It is not the machine-to-machine tool. Using it for a straight computer move imports a fresh config over your real state instead of carrying it across.
What I Tried First (And Why It Failed)
My first attempt was the obvious one. Zip ~/.openclaw, scp it to the new box, unzip, start the gateway. The agent came up clean, answered a message in under a second, and had no idea who I was.
Attempt two was re-running onboarding and pasting the API keys back in. That restored model access, but sessions were still empty, Telegram was still logged out, and my cron jobs were nowhere. I had rebuilt a working stranger.
Attempt three was copying the folder while the gateway was running. The database failed its startup migration check with “startup migrations did not complete cleanly”, which cost me an hour and taught me the rule that matters: stop the gateway before you take the snapshot, and use the backup command instead of a folder copy.
The Fix
Fix 1 (free, 2 minutes): Point the new machine at the right state directory
If your data is already on the new machine and only the path is wrong, do not migrate anything. Start the gateway with the same profile or state directory the old one used.
OPENCLAW_STATE_DIR=/path/to/migrated/openclaw openclaw gateway restart
openclaw doctor
The gateway reads its state path at startup, so a reload is not enough here. A full restart is. Then confirm openclaw status reports the path you expect, and your sessions will be back. This single step fixes the majority of “it forgot everything” cases where the files were never actually lost.
Fix 2 (free, 15 minutes): Move it with the backup and restore flow
This is the method that works every time. On the old machine, with the gateway stopped, create a verified archive:
openclaw gateway stop
mkdir -p ~/Backups/openclaw
openclaw backup create --output ~/Backups/openclaw --verify
Transfer the .tar.gz over scp or an encrypted drive. On the new machine, restore into a staging directory rather than over a live install:
openclaw backup restore <archive.tar.gz> --target ~/openclaw-restored
Restore never activates in place. Read the manifest.json in the restored folder and move the state asset and workspace to their recorded destinations, or point OPENCLAW_STATE_DIR at the restored state asset directly. Check ownership matches the user who will run the gateway, then finish with:
openclaw doctor
openclaw gateway restart
openclaw status
Expected result: channels still connected, sessions listed, workspace files present. If a channel asks you to log in again, that is the next fix, not a failure of this one.
Fix 3 (free, 10 minutes): Reinstall plugins and re-auth what ratchets
Two things reliably do not survive a move. Plugin node_modules trees need reinstalling, because absolute paths and native builds do not transfer. And channel credentials that ratchet, WhatsApp being the main one, desynchronize if the restored state is older than the phone’s current session.
Reinstall plugins through the CLI, then re-pair WhatsApp rather than fighting the restored session. Then check paired devices and nodes, since the new machine counts as a new node. Your agent’s behaviour is intact at this point; only the transport layer needs re-attaching.
Fix 4 (paid, 20 minutes): Stop moving the agent at all
If this is the second or third migration in a year, the pattern is the problem, not the commands. Laptops sleep, drives fill up, and every hardware change means another evening of state surgery. Moving the agent to a managed host turns it into a one-time move with someone else owning uptime, upgrades, and backups.
ClawTrust runs OpenClaw for you and provisions it in about five minutes. Lite is $29 per month with your own free NVIDIA key, Starter is $79 with higher limits and priority support, and Pro is $159 with Python execution and a $10 monthly AI credit. All plans include a 5-day free trial.
When It’s Worth Paying
Do the free fixes first. If your agent runs on a machine that stays awake and you move hardware roughly once a year, the backup and restore flow is genuinely enough. Paying for hosting buys you nothing you need.
It makes sense in two cases. You have already migrated twice and lost state both times. Or you want the agent off your own hardware entirely, so a failed disk is somebody else’s ticket and not your weekend.
At $29 per month, the honest comparison is your hourly rate against the four to six hours a bad migration costs, plus the week of retraining a fresh agent needs. For a solo operator, one avoided migration usually covers a year of the Lite plan.
Frequently Asked Questions
Yes, if you copy the whole directory while the gateway is stopped. No, if you copy only openclaw.json or only the workspace folder. Model auth lives in state/openclaw.sqlite, agent profiles in agents/<agentId>/agent/, and channel logins under credentials/. A partial copy produces an agent that works but remembers nothing.
Two gateways are running with the same bot token. Messages get picked up twice, so you see duplicate replies and split state. Stop the gateway on the old machine and shut down its service, then confirm only one process is listening on port 18789 before you test again.
Not while the gateway is running. SQLite writes through a WAL file, so a raw copy can capture a database and WAL from different moments and leave you with a torn or corrupt store. Use openclaw backup create –verify, which quiesces the data properly, or stop the gateway first if you must copy files manually.
Channel state transferred, but the login did not survive. WhatsApp ratchets its credentials, so a restored session older than the phone’s current one desynchronizes and must be re-paired. Telegram normally reconnects once its token is present. Re-pair the channel, then run openclaw doctor to confirm no account is missing a token.
Migrate to a VPS if you are comfortable with SSH, service units, and backups, and you move machines rarely. Use managed hosting if the agent must stay online, if you have lost state during a previous move, or if you would rather not be the person debugging a database at midnight. The migration commands are the same either way, the difference is who owns the box afterwards.
Do This First
Three steps, ten minutes, in this order.
- Stop the old gateway and confirm nothing is listening on port 18789. Half of migration problems are actually two agents running at once.
- Compare
openclaw statuson both machines. If the state paths differ, fix the path before you move a single file. - Move state with
openclaw backup create --verify, restore to staging, then runopenclaw doctor. Never copy a live SQLite file.
If the move goes cleanly, keep doing it this way and you will not need anything else. If you have lost state twice, or your agent outgrew the machine it lives on, the upgrade path is a managed host with backups and uptime included, and the upgrade playbook covers what to check after any version change. For the always-on side of this, see running an agent 24/7, and if the new box refuses to serve at all, the gateway startup fix picks up from there.
This post contains affiliate links. If you buy through them, I may earn a small commission at no extra cost to you.

