Black Branch/Docs
All sections

Disk space and the database

This page is for you when your server's disk is filling up, or when you want to know how the database is kept up to date. After reading it you can find what uses space and get it back safely, and you know which secrets can and cannot be changed.

Where the space goes

What Where How it grows
Software images Docker's data folder (usually /var/lib/docker) Each release's images. The running release and the one before are kept so an update can go back. Older ones are removed after each successful update.
The database A Docker volume Chat history, accounts, points, payment records. Grows with your community.
The homeserver's media A Docker volume Everything uploaded to rooms and direct messages, at most 20 MB per file. Messages expire under the retention rules, but uploaded files do not expire.
Local backups /opt/blackbranch/backups/ Only when backups go to this server. restic stores each piece once, so 7 daily and 4 weekly snapshots usually take little more than one full copy plus what changed.
Logs Docker's data folder Capped at three 10 MB files per service.
Old releases' folders /opt/blackbranch/releases/ Removed like the images.

To see free space on the disks that matter:

df -h / /var/lib/docker

To see what Docker's images, volumes and build cache take:

sudo docker system df

To see how much the local backups take:

sudo du -sh /opt/blackbranch/backups

The Doctor turns red when less than 15 % is free where the install lives or where Docker keeps its data, and the server's daily check sends an alert for the same (Alerts from the server). An update also refuses to start with less than about 5 GB free where Docker keeps its data, because it downloads the new release's images beside the running ones.

Getting space back

  1. Remove image layers nothing uses:

    sudo docker image prune
    

    Adding -a also removes every image no container is using right now. Both are safe for the install: anything the running release needs is in use. After -a, the previous release's images are gone too, so a rollback would have to download them again.

  2. Remove the build cache (large on an install made from a copy of the source):

    sudo docker builder prune
    
  3. If local backups are the problem, send backups to a bucket instead (Admin Panel → Site → Site, card Backups), or keep fewer snapshots.

  4. If the database or media are the problem, the server has become too small for your community. Grow the disk (Growing the same server).

⚠ Never delete Docker volumes by hand (docker volume rm, docker system prune --volumes). They hold the database and the homeserver's media and signing key.

The database

One Postgres server (version 18, with the pgvector extension for the chat bot's memory) holds three databases. Each has its own account and password from .env.

Database Used by
stream The site, the chat service and the ingest service: accounts, chat, points, payments, settings
synapse The homeserver
mas The homeserver's sign-in service

How it is upgraded

The site's database is changed by migrations: numbered steps, applied in order, each recorded once it is applied. They run every time the install starts, before any service that uses the database. A new install starts from the release's complete baseline instead of replaying every step. Each migration runs as one unit, so one that fails part-way leaves nothing of itself behind.

Database upgrades need nothing from you. An update brings new migrations, and its start applies them after the backup it made. The homeserver and its sign-in service upgrade their own databases the same way when they start.

The Doctor's row The database is at this release's version compares the database with what the release expects. If it is red, apply the migrations now:

sudo blackbranch migrate

It prints what it did, or why it stopped. sudo blackbranch logs migrate shows the same.

Postgres major versions

An update never moves the database to a new major version of Postgres (for example 18 to 19). That needs the data converted, not only a newer program. The update check refuses such a release with a message saying so, and the project announces that move as its own step, with its own instructions.

Secrets cannot be changed in this release

The secrets in .env were made once, at install, and the data they protect is locked with those exact values. This release has no command to change them, and changing one by hand breaks what it protects (which secret protects what). The same is true of the backup passphrase: a new one would not open any existing backup.

What you can change:

If you think one of the install's own secrets was exposed, leave it in place and write to security@blackbranch.app (see Security for owners). A supported way to replace them is on the way.

⚠ To confirm: the full steps to follow when one of the install's own secrets was exposed, once a supported way to replace them exists.

Next: Help

← Running it