The server command
This page is for you when you are at the server's terminal. It lists every blackbranch command you will type, what each one does, and when to use it.
blackbranch is the install's own command, at /usr/local/bin/blackbranch. You use it to check, back up, restore, update and repair your site. It works when the site is down, which is why it is a command and not a page.
Run it with sudo from your usual account. It reads the install's settings file, which only root can open. Without sudo it stops and tells you to use it. To see the list of commands:
blackbranch help
The help also lists every setting that takes effect only when its service restarts, and what to run after changing one.
The command never prints a secret. Every command that changes something either finishes, or leaves things as they were and says which.
Everyday commands
| Command | What it does |
|---|---|
sudo blackbranch status |
Shows the domain and front door, the release and channel, federation, whether setup is finished, the last backup and restore check, the last update check and update, and each service's state. Also says whether a setting changed in the Admin Panel is still waiting for its service to restart. Exit status 1 when a service is not healthy. See Status. |
sudo blackbranch doctor |
Runs every health check and prints a fix line under each problem. Exit status 1 when a check fails. See Health and the Doctor. |
sudo blackbranch doctor --report |
Writes a report you can share when you ask for help. It holds no secret, chat text, viewer id or domain. See A report to share. |
sudo blackbranch logs <service> |
Prints the last 200 lines of one service's log. Add -f to keep following it. |
sudo blackbranch restart <service> |
Restarts one service and waits up to three minutes until it is healthy again. |
sudo blackbranch backup |
Backs up now, to the target set in the Admin Panel. |
sudo blackbranch backup list |
Lists the snapshots at the backup target. |
sudo blackbranch backup key |
Prints this server's SSH key, for a backup target reached over SFTP. |
sudo blackbranch restore latest --verify |
Restores the newest backup into a throwaway container and checks it. Changes nothing. |
sudo blackbranch update --check |
Reads the release feed and says what is available. |
sudo blackbranch update |
Reads the feed and, if there is a newer release, asks before installing it. |
sudo blackbranch set <KEY> "<text>" |
Changes one display value, such as the site's name, and restarts what reads it. See Changing a display value. |
sudo blackbranch alerts test |
Sends a test alert where the server's alerts go (the Admin Panel's alerts topic, or the ntfy topic or email command set in .env), and says whether it went out. See Alerts from the server. |
sudo blackbranch mail test <address> |
Sends one test message through the mail server set in Admin Panel → Site → Site, card Mail, and says whether it went out (check that inbox, and its spam folder). The Doctor's Mail row shows the answer. See Mail. |
sudo blackbranch discord on |
Switches the Discord bridge on and brings the install to that state. It refuses until the bot token is saved on Admin Panel → Site → Discord. off switches it off. |
sudo blackbranch federation |
Shows whether federation is on. on or off after it switches it. See Federation. |
The services
Wherever a command takes <service>, use one of these names:
| Service | What it is |
|---|---|
web |
The website |
stream-api |
The chat service |
stream-ingest |
The ingest service: reads the platforms' chats and runs the chat bot |
postgres |
The database |
synapse |
The homeserver |
mas |
The homeserver's sign-in service (MAS) |
caddy |
The router that receives every visitor |
cloudflared |
The Cloudflare tunnel (tunnel mode only) |
ooye |
The Discord bridge (only while it is switched on) |
migrate also appears in status. It is a one-time step that applies database changes at every start, then stops.
Changing a display value
sudo blackbranch set SITE_NAME "Casey's Corner"
This changes one value in .env, restarts what reads it (a few seconds), and checks that the site comes back healthy. If it does not, the old value is put back by itself.
The values you can change this way are listed on Display values. A value can be up to 300 characters and cannot contain $, ", \ or a line break. The domain, the homeserver's name and the secrets can never be changed.
Commands for bigger jobs
| Command | What it does |
|---|---|
sudo blackbranch restore <snapshot> |
Brings a backup back. Use latest or a snapshot id from backup list. It asks you to type the domain first. Options: --yes skips the question, --with-env (a new server) takes the backup's settings file too, --from <address> reads backups from a bucket or SFTP server this server has no settings for. See Restoring a backup. |
sudo blackbranch update --dry-run |
Downloads and checks the newest release and tries your settings file against it. Changes nothing. |
sudo blackbranch update --channel beta |
Changes which release channel this server follows (beta or stable), then checks the feed. |
sudo blackbranch update --apply <version> |
Installs exactly that release, if the signed feed still names it. Use it to try again a release the nightly timer stopped retrying. See Rollback. |
sudo blackbranch health |
Runs the check an update runs after it switches releases: the Doctor checks an update can affect, a live chat connection, and a sign-in round trip. |
sudo blackbranch render |
Writes the configuration of the router, the homeserver and its sign-in service again from .env and the switches, and restarts what changed. |
sudo blackbranch up |
Brings the whole install to its configured state: settings file changes, database changes, configuration, then every service in order, waiting until all are healthy. Safe to repeat. |
sudo blackbranch migrate |
Applies any database changes now. They also run at every start. |
sudo blackbranch matrix bootstrap |
Creates the community space, #general and #forum as your account, if they do not exist yet. Safe to repeat. |
sudo blackbranch setup-link |
Prints the setup link while no admin account exists. Add --new to make a fresh one; the old link stops working. |
sudo blackbranch user admin <name> on |
Makes an account an admin; off removes one, never the last. <name> is a username on your site or a whole @user:server, and the account must have signed in once. The moderation log records it. This is how you get an admin back when nobody can sign in as one; in the panel, admins do the same in Admin Panel → Site → Moderators, card Admins. |
Commands the install runs itself
You will not type these. They are listed so nothing on the server is a mystery.
| Command | Run by |
|---|---|
apply-install |
The last setup page. It writes the setup pages' display values into .env and restarts the site once. After setup, use set. |
update --auto |
The nightly update timer |
update --reconcile |
The boot service that finishes an interrupted update |
backup --scheduled and restore latest --verify --scheduled |
The nightly backup and weekly check timers |
alerts check |
The daily check timer, each morning: disk, backups and, in direct mode, certificates |
process-requests |
The watcher for the site's requests (below) |
install-files |
The installer and every update. It puts the release's own files in place on the server. |
matrix bootstrap --as <name> |
Testing only: bootstraps the rooms as a named account before setup has made yours |
How the site asks the server for things
The site never controls Docker or the server. When you press a button that needs the server, the site drops an empty file into /opt/blackbranch/requests/. The file's name is the request. A watcher on the server runs the one fixed action that name stands for, deletes the file, and writes the answer to /opt/blackbranch/results/, a folder only root can write.
A site that was taken over could therefore only ask for actions from this short list. It cannot pass in a command, and it can restart only stream-api, stream-ingest and web. An unknown name is refused. While an update runs, only requests that read are carried out; the others are answered "an update is running".
| Request | What the server does | Asked by |
|---|---|---|
restart-stream-api, restart-stream-ingest, restart-web |
Restarts that service | The Admin Panel, after a setting that applies at restart |
render |
Runs blackbranch render |
Saving the federation or sign-up switch, a lockdown, setup's last step |
matrix-bootstrap |
Creates the community rooms | Setup's community page |
apply-install |
Writes the setup pages' display values | Setup's last step |
site-icons |
Checks and installs the five icon files you uploaded | Setup's icon upload |
recovery-sheet |
Hands the backup passphrase to the setup page, once | Setup's recovery page |
doctor |
Gathers the server's facts for the Doctor | Check again on the Doctor page |
backup, backup-test, backup-key |
A backup; a backup and a restore check; the SFTP key | The Admin Panel, and setup's backup step |
update-check, update-v<version> |
Reads the feed; installs exactly that release if the signed feed still names it | Admin Panel → Updates |
Next: Health and the Doctor