Skip to content

Moving to a new server

To move AFTAB to another server you make a backup on the old one and install on the new one with it. Clients, keys, plans, resellers and settings all come along, including the secrets key, which protects the panel’s secrets: the bot tokens and the two-factor secrets. The panel’s signing key, which bridges and servers trust, is in the database too, so it moves with it. The step-by-step guide with restore checks and host programs (Tor, AmneziaWG, local SOCKS) is Move to a new server. This page keeps the same order as a short reference.

  1. Tell the bridges and servers where the panel will be. Bridges, exit servers and fleet servers all keep the panel’s signing key (which comes along in the backup) and reconnect by themselves once HTTPS is back up on the new server. If the panel keeps the same domain, pointing that domain at the new server and setting up HTTPS there is enough. If the panel moves to a new address, add the new panel’s https address under Other addresses of this panel (the node_addresses setting) before the move and wait for every node to sync once so it saves the address. That box appears on Bridges only for the owner when the panel is on HTTPS and at least one bridge exists; if you have only exit or fleet servers, set node_addresses with PUT settings in the API or sudo aftab set node_addresses https://… before the move.
  2. Decide what clients will connect to. Clients keep working when they reach the new server at the same address. If their configs name a domain, point the domain at the new server when it is ready. If their configs name the old server’s IP address, they cannot reach the new one: install with AFTAB_PUBLIC_HOST set, as below, and they import their link again.
  3. Make a backup on the old server. Run sudo aftab backup /root/aftab.db, or press Backup on the Overview page and then Download backup, which gives an encrypted .enc file. See Backups and restore.

Copy the file to the new server, then run the installer with AFTAB_RESTORE before bash:

Terminal window
sudo AFTAB_RESTORE=/root/aftab.db \
bash -c "$(curl -fsSL https://raw.githubusercontent.com/aftabIR/aftabWG/main/install.sh)"
  • An encrypted .enc backup also needs AFTAB_RESTORE_PASSWORD, the old admin password.
  • If the backup is at a web address, use AFTAB_RESTORE_URL=https://… instead of the file. Only https is accepted.
  • To change the address put in client configs, add AFTAB_PUBLIC_HOST with the new IP or domain.
  • When nobody types, add AFTAB_ACCEPT_EULA=1 to accept the licence.

AFTAB_RESTORE and AFTAB_RESTORE_URL work only on a fresh install, on a server that has no AFTAB database yet. On a server that already runs AFTAB, use sudo aftab restore FILE with the panel stopped instead: see Backups and restore.

The installer restores the database instead of making a new panel. It clears any setting that names a certificate file that is not on this server, and it asks about HTTPS again.

  1. Sign in with the old server’s admin username and password: they came with the backup. The installer reminds you.
  2. HTTPS certificates stay behind, because they are files of the old server. Set HTTPS up again with Settings → Panel → Get a certificate, or from the command line: see HTTPS.
  3. AmneziaWG and Tor install themselves on the new server when the backup has an AmneziaWG inbound or a Tor exit: the restore (or aftab restore) tells you so, and those links stay down for a few minutes until the install ends. A SOCKS5 exit that points at a program on the same server is not installed for you: start that program, or the restore names it.
  4. Open the panel’s TCP port and the VPN’s UDP ports in the new server’s cloud firewall, as the installer prints.
  5. Point the domain, if clients use one, at the new server, and check that a client connects and that bridges and exit servers show as connected.
  6. When the new server works, switch the old one off, or remove AFTAB from it with sudo aftab uninstall, so that two servers do not both answer for the same clients.
  • “there is no file”. The path in AFTAB_RESTORE is wrong on the new server.
  • A node is named while the installer runs. A bridge or exit that runs the node program, or a fleet server, joined after the backup, or its state number moved. A WARP exit, a SOCKS proxy or a hand-written .conf is not named. The same lines as aftab restore: a node that joined later will not know this panel and joins again with a new install command. See Backups and restore.
  • “is an encrypted backup: set AFTAB_RESTORE_PASSWORD”. Give the admin password the backup was made with.
  • “the backup could not be opened (the password?)”. The password is wrong, or the file is damaged.
  • “AFTAB_RESTORE_URL must be an https:// address”. A backup is not downloaded over plain http from another machine.
  • “run this installer again with AFTAB_RESTORE_LOSE_SECRETS=1”. The file is a copy of aftab.db made by hand, not a backup, so it carries no secrets key and its secrets do not open here. Make a backup on the old server with sudo aftab backup and use that. If the old server is gone, run the installer again with AFTAB_RESTORE_LOSE_SECRETS=1: the copy is restored and its secrets are given up (every bridge and exit joins again, the tokens are entered again); see Backups and restore.
  • Clients cannot connect. Their configs name the old address. Point the domain at the new server, or set AFTAB_PUBLIC_HOST and have them import their link again.
  • A bridge or server stays offline. It did not know the new address. Add the address under Other addresses of this panel while the old panel still runs, or run the install command of the bridge again: see Iran bridges.
  • Sealed secrets do not open. The backup did not carry the key. Enter the tokens again: see Security.