Skip to content

Back up and restore ​

A backup is a full copy of the database: settings, users, lines, the catalog and, if you want, the connection history. It is encrypted with your instance master key.

Keep the master key safe ​

Backups are encrypted with /opt/bitstream/data/control/master.key. Without that key, nobody can read a backup, and that includes you.

Copy the master key off the server

Store master.key somewhere other than the server, for example in your password manager. If the server dies and you only have the backups, you need it to restore.

Make a backup now ​

bash
curl -s -X POST $PANEL/backups \
  -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{"include_history": false, "note": "before the upgrade"}' | jq '{id, status}'

Connection history can be large. Leave it out unless you need it.

The backup runs in the background. Check it:

bash
curl -s $PANEL/backups -H "Authorization: Bearer $TOKEN" | jq '.data[] | {id, kind, status, size_bytes, created_at}'

status goes from running to done (or failed with an error). Files are stored under /opt/bitstream/data/control/backups.

Download a backup ​

bash
curl -s -o bitstream-backup.bsb $PANEL/backups/12/download -H "Authorization: Bearer $TOKEN"

Back up on a schedule ​

Scheduled backups are on by default: every day at 04:00 in the panel time zone, keeping the newest 7. In the panel, open Backups and use Automatic backups to change it. With the API, set the backups settings group:

bash
curl -s -X PATCH $PANEL/settings/backups   -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json'   -d '{"schedule": "0 3 * * *", "keep": 14, "include_history": false}'
  • schedule is a cron expression with 5 fields (minute, hour, day, month, weekday). An empty schedule turns it off.
  • keep is how many scheduled backups to keep, from 1 to 365. Older scheduled backups are deleted. Manual backups are never deleted by the schedule.
  • If several controls run, only one of them takes each scheduled backup.

Restore ​

Restore replaces everything

A restore replaces the whole database. Everyone is signed out and the nodes resync. Bitstream takes a pre_restore backup first, so you can undo it.

A restore needs a signed in user, not an API key. You send your password again, and your 2FA code (or a recovery code) when two-step sign-in is on:

bash
curl -s -X POST $PANEL/backups/12/restore   -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json'   -d '{"confirm": "RESTORE", "password": "your-password", "totp_code": "123456"}'

The restore runs in a single transaction. If it fails, the database stays as it was.

ErrorMeaning
400 invalid_passwordWrong password.
400 totp_invalidWrong or missing 2FA code.
409 backup_not_localThe file was uploaded with another master key.
429 rate_limitedMore than 5 password tries in 15 minutes.
403 api_key_not_allowedYou used an API key. Sign in instead.

Upload a backup file ​

You can upload a .bsb file you downloaded from this panel, then restore it. Upload also needs a signed in user:

bash
curl -s -X POST $PANEL/backups/upload   -H "Authorization: Bearer $TOKEN"   -F file=@bitstream-backup.bsb | jq '{id}'

Only backups from this installation can be restored

A backup is sealed with the master key of the panel that made it. If you upload a file with another master_key (32 bytes in base64 or hex), the panel keeps it so you can download it again, but restore refuses it with 409 backup_not_local. This stops anyone with a foreign key from pushing their own data into your panel.

To move a panel to a new server, the new control must run with the old master.key, so copy that file to /opt/bitstream/data/control/master.key on the new server first. The panel seals its own stored secrets with that key, so the key has to be in place before the new control stores anything. The full move procedure is not tested end to end yet.

The backup and restore steps need pg_dump, pg_restore and psql on the control server. The installer puts them there with PostgreSQL.

Bitstream documentation