Skip to content

Backups and restore

A backup is one file with everything AFTAB keeps: the settings, the inbounds, the clients and their keys, the plans, the resellers, and the key that protects the panel’s secrets. The panel makes one every day by itself. You can make one at any time, and a restore puts a whole panel back from one.

On the Overview page, the Backup button opens the backup window. Back up every day is on from the start. Time of day (server time) chooses the hour, 03:00 by default, and Copies to keep chooses how many to keep: the panel keeps the newest 7 unless you change it (the autobackup_keep setting) and removes older ones. On a phone, Backup is in the General actions menu.

The copies are in /etc/aftab/backups/, named like aftab-20260117-030000.db, in a folder only the panel can open. A copy on the same server is lost together with the server, so keep one off the server: the panel can send the daily backup to Telegram, or you can download it. If no daily backup has been made for 48 hours, the panel alerts you.

  • Back up now in the backup window saves a copy on the server at once.
  • Download backup gives you a file to keep elsewhere.
  • On the server, sudo aftab backup writes a dated file in root’s home folder, /root, because with sudo’s default settings sudo runs the command with root’s home, and sudo aftab backup FILE writes the file you name.

The file holds every key and the key that protects the panel’s secrets: the bot tokens, the two-factor secrets, the WARP and SOCKS5 logins and the signing keys. Anyone who has an unencrypted backup can read all of that, so guard backups like the panel’s password.

sudo aftab backup writes an unencrypted file, readable only by root, and it carries the secrets key too. Guard it: move it off the server over a safe channel, and delete the copy when you no longer need it.

What leaves the panel can be encrypted. With Encrypt backups with the admin password on (the backup_encrypt setting, on from the start), a backup you download, or that goes to Telegram, is an encrypted .enc file that opens only with the admin password in use when it was made. The copies kept on the server are not encrypted. To send the daily backup to Telegram, switch on Daily backup to Telegram (tg_backup) in Settings → Integrations → Telegram, which is hidden until you turn on Selling and operator tools in Settings → Panel (the full_mode setting). It goes gzipped, as an .enc file while backups are encrypted, and a file over 49 MB cannot go: download it from the panel instead. Send it only if you trust Telegram with it.

To open an encrypted backup without the panel, run aftab decrypt-backup FILE. It asks for the admin password the backup was made with and writes the plain database beside it, or to the file you give as a second argument. The plain database carries the secrets key too: delete it when you are done.

In the backup window, drop a backup file on the restore area, or press Restore beside a copy saved on the server. For an .enc file, type the admin password in use when it was made. A restore replaces everything on this server, including the admin login: sign in afterwards with the admin account of the backup. Before it replaces anything the panel saves a copy of what it has, kept beside the daily backups, and the panel restarts.

If the panel cannot start, restore from the server, with the panel stopped:

  1. sudo aftab stop
  2. sudo aftab restore FILE, where FILE is a backup or one of the copies in /etc/aftab/backups/. For an .enc file, run aftab decrypt-backup on it first.
  3. sudo aftab restart

The database it replaces is kept beside it, with .before-restore- and the time in its name. The secrets key comes in with the backup and becomes this server’s, so the sealed secrets open again.

  • “the panel is running: stop it first”. sudo aftab restore works only with the panel stopped. Run sudo aftab stop first.
  • “This backup is encrypted”. Enter the admin password the backup was made with. A wrong password, or a damaged file, is refused.
  • “This is not an AFTAB backup”. Choose a .db, .db.gz or .enc file.
  • The Telegram backup does not arrive. Telegram is off, Daily backup to Telegram is off, or the file is over 49 MB.
  • “No automatic backup”. The panel alerts you after 48 hours without one: look at Back up every day and the free space on the disk.
  • A node joined after this backup. Restore and aftab restore name it before the database is replaced. The name is a bridge or an exit that runs the node program, or a fleet server. A WARP exit, a SOCKS proxy or a hand-written .conf is not a node, so it is not named. That node is not in the backup, so it will not know the restored panel and joins again with a new install command. A node that is in the backup is named with its state number there and the number on this server; the next sync signs above the number the node took. The installer prints the same lines when AFTAB_RESTORE is set.
  • “its secrets open neither with a key it carries nor with this server’s”. The file is a copy of aftab.db made by hand, not a backup, so it carries no secrets key, and this server’s key does not open its secrets. Restore a backup made by the panel or by aftab backup, or put the secrets.key of the server it came from in /etc/aftab/ first. To restore it all the same, giving up the secrets it names: sudo aftab restore --lose-secrets FILE. The panel then makes a new key for sign-in and a new key for bridges and servers, every bridge and exit joins again with a new install command, and the tokens are entered again; see Security.

To move to another server with a backup, see Moving to a new server.