Skip to content

Back up and maintain

Back up

Copy the data folder while the daemon is stopped. Stop it the way you started it:

Started withStop it
wx daemon startwx daemon stop
systemd (wx daemon install)systemctl --user stop agent-wechat-native
Docker Composedocker compose stop

Then archive the folder:

Terminal window
tar -czf wechat-backup.tgz -C ~ .local/share/agent-wechat

If you logged in with --official, the WeChat files live outside that folder. Add them to the command:

Terminal window
tar -czf wechat-backup.tgz -C ~ .local/share/agent-wechat xwechat_files .xwechat

Back up both. The data folder holds queued sends and recall records, but not chat history. The WeChat profile holds the history, but without the data folder you lose the rest.

With Docker Compose, the data folder is the native-data volume (/var/lib/agent-wechat in the container), not a folder in your home directory. Back up that volume instead. If you use OpenClaw, also back up its consumerStateDir; it records where OpenClaw is in the message stream.

Upgrade

Back up first. An upgrade can change the data folder’s format, and an older wx can’t open a folder a newer version has upgraded. See Storage and backups.

  1. Install the new version with the same method you used to install it.

    Terminal window
    npm install -g --allow-scripts=@agent-wechat/cli @agent-wechat/cli
  2. Restart the daemon so it runs the new version.

    Terminal window
    wx daemon restart
    wx --json version

    wx daemon restart also restarts the systemd service made by wx daemon install. With Docker Compose, run docker compose pull and docker compose up -d to recreate the container from the new image. If OpenClaw runs the daemon for you (managed mode), restart the Gateway.

Sign out or remove a profile

List profiles with wx accounts list. Use the account ID from that response:

Terminal window
wx --account ACCOUNT_ID auth login
wx --account ACCOUNT_ID auth logout

Use wx --account ACCOUNT_ID auth logout --local to sign out on the daemon and keep saved credentials without sending a logout request to WeChat. Both forms stop automatic reconnection.

After sign-out completes, remove the profile from the hub by repeating its exact ID:

Terminal window
wx accounts remove ACCOUNT_ID --confirm ACCOUNT_ID
{ "accountId": "ACCOUNT_ID", "removed": true, "filesRetained": true }

Removal unregisters the profile and keeps its local files. wx auth forget --yes is a separate action that forgets saved sign-in credentials; it does not remove the profile.

Rotate or revoke API tokens

  1. Create a token for the new client, limited to the account and scopes it needs. See API tokens for the scope list.

    Terminal window
    wx tokens create my-script --accounts ACCOUNT_ID --scopes read --scopes send

    The token is printed once, in the token field. Store it in your client’s configuration.

  2. Find the old token’s ID and revoke it.

    Terminal window
    wx tokens list
    wx tokens revoke TOKEN_ID

Change where data is kept

wx doesn’t move any files when you change the location. A new folder starts empty, with a new owner API token and no profiles, unless you copy the old data there first.

  1. Stop the daemon and back up the data folder (see Back up).
  2. Copy the data folder to the new location yourself.
  3. Set the new location with dataDir in ~/.config/agent-wechat/server/config.toml, or pass --data-dir to wx. See Configuration.
  4. Start the daemon and check wx accounts list.

Profiles added with --official stay where they are; only the data folder moves.

The default location for each platform is in Storage and backups.