Moving to a new server
This page is for you when you want your site on a different server, or have lost the one it ran on. After reading it you can make a planned move, rebuild from backups, or grow the server you have.
A move is a restore onto a new server. You install the new server with the same domain and front door, and restore your newest backup onto it together with its settings file.
Growing the same server
Adding memory, processors or disk to the server you have needs nothing from Black Branch. Shut it down, resize it at your provider, and start it again. Everything comes back on its own.
If you grew the disk, check that the provider also grew the partition. df -h / shows the new size. Some providers need a reboot or a command for that.
Before you move
- The new server must meet the same requirements (Before you start).
- It must use the same domain. A restore refuses a backup of another domain, because the homeserver's name can never change.
- It must use the same front door (tunnel or direct).
- Have the backup passphrase from your recovery sheet at hand.
The new server gets the release the installer brings. The restore keeps it, and applies any database change newer than the backup when it starts.
Recommended: keep the old server until the new one is green on the Doctor, and if you can, try the move on a spare server first. Each part of a move is built and tested (the install with
--moving, the restore with--with-env, and every refusal below); the project's own rehearsal of a whole move, from one fresh server to another, is still to come.
A planned move, step by step
-
On the old server, make a fresh backup:
sudo blackbranch backupThen stop the install, so nothing is written after the backup:
sudo docker compose --project-directory /opt/blackbranch stop -
Make the backups reachable from the new server.
- Backups on the old server's own disk: copy the folder
/opt/blackbranch/backups/across, for example withsudo rsync -a. On the new server it must end up at the same path, owned by root. - A bucket or SFTP server: the new server can read it directly in step 4. For SFTP, add the new server's key to that account first: once the new server is installed,
sudo blackbranch backup keyprints it.
- Backups on the old server's own disk: copy the folder
-
Install the new server with the same domain and front door, and add
--moving(Installing). For tunnel mode:curl -fsSL https://blackbranch.app/install.sh | sudo bash -s -- --domain example.com --mode tunnel --movingUse
--mode directfor direct mode. With--moving, the installer sets everything up but starts nothing, makes no tunnel, skips the DNS check and prints no setup link. The restore brings all of that back. -
Restore with the settings file:
sudo blackbranch restore latest --with-envFor backups in a bucket or on an SFTP server, add
--fromand the address, for example:sudo blackbranch restore latest --with-env --from s3:https://<endpoint>/<bucket>The new server's own passphrase does not open the old backups, so it asks for the one on your recovery sheet. A bucket also asks for its two keys. The restore then replaces the new server's
.envwith the old one (keeping the new one beside it as.env.before-restore-<time>), rebuilds the empty database with the old passwords, restores the data and keys, and starts the site. -
Point the front door at the new server.
- Tunnel mode: nothing to change. The restore brings back your site's own tunnel, which now connects from the new server, and its DNS records already point at it. Keep the old server stopped: two servers on one tunnel would both answer.
- Direct mode: change the three DNS records (your domain,
api.andmatrix.) to the new server's address.
-
Check with
sudo blackbranch doctor, and sign in. When everything is green, delete the old server.
Rebuilding after losing a server
Follow the planned move without step 1. Install a new server with the same domain, front door and --moving, then restore the newest backup with --with-env (and --from for a bucket or SFTP server). Anything written after the last backup is lost: at most a day's worth with the nightly schedule.
What you need: the backups (in a bucket, on another server, or a copy of the local backups folder) and the backup passphrase. Backups kept only on the lost server are lost with it.
Tunnel mode: when the tunnel does not match
You installed without --moving. The installer then signs in to Cloudflare. If the old tunnel still exists, it stops and tells you to run it again with --moving; do that. If it made a new tunnel instead, the restore keeps the new server's own tunnel and says so, because its DNS routes are the ones in place. Delete the old tunnel in Cloudflare's dashboard (Zero Trust → Networks → Tunnels) once the old server is gone.
You deleted the old tunnel before restoring. Make a new tunnel in Cloudflare's dashboard, route your domain, api. and matrix. to http://caddy:80, and give the new server its token. This command asks for the token without showing it, and replaces the tunnel the server uses:
sudo /opt/blackbranch/release/install/install.sh --tunnel-token
To read the token from a file instead, use --tunnel-token-file <file>. The steps for a dashboard tunnel are on Using a tunnel you made in the dashboard.
What a restore refuses, and why
| The restore says | Why |
|---|---|
| the snapshot is of old.example.com, and this box was installed for example.com | A backup of another domain cannot become this install. Install with the same domain. |
| the snapshot was made with other secrets than this box's .env | You left out --with-env. On a new server, add it. |
| --with-env is for a new box, and this one holds a site that finished setup | Taking another .env would make this server's own data unreadable. Restore onto a server whose setup link was never used. |
| that passphrase does not open these backups either | The passphrase you typed is not the recovery sheet's. |