Skip to main content

Storage and Backups

Protect the bot's settings and history by backing up the database with pg_dump and keeping a separate copy of the installation key.

The Data Volume

The container keeps everything in one data volume at /config. With docker run, it is the host folder you pass with -v, such as /path/to/discord-stonker-bot. Compose mounts a volume named stonker-data, and docker volume ls lists it as discord-stonker-bot_stonker-data.

PathWhat it holds
/config/database/The PostgreSQL database, with every setting, account, token, invite page image, job, and log
/config/keys/The private key directory, with mode 0700
/config/keys/installation.keyThe installation key, with mode 0600

Every start changes the ownership of the whole state tree to PUID:PGID; each ID must be from 1 through 60000. docker compose down keeps the volume, and only docker compose down --volumes deletes it.

Upgrading a /data Install

Mount the same host folder at /config instead of /data. Files from the old layout first appear at the same relative paths, then the start moves postgres/ to database/ and secrets/credential.key to keys/installation.key without overwriting either destination.

An unchanged old run line that mounts only /data still starts safely. Nova resolves /data as the state directory, performs the same layout migration there, and logs a warning to change the mount to /config. If current state appears in both roots, it uses /config and leaves both copies intact for manual review.

The Installation Key

The appliance creates the installation key on its first start as 64 lowercase hexadecimal characters followed by a newline. Its file mode is 0600 inside the mode-0700 keys/ folder, so only the services' user can read it. It encrypts the Bot Token, every feature secret, every authenticator app secret, and the secret fields of every notification destination.

Accounts, passwords, passkeys, sessions, and access tokens don't use the key, because the panel stores hashes or public keys for them. A pg_dump backup doesn't include the key.

Keys From Version 4.0

Version 4.0 kept the key as 32 raw bytes at /config/secrets/credential.key. On the first start of a newer version, the appliance moves that file to /config/keys/installation.key, verifies it against the database, and atomically rewrites the same bytes in the hexadecimal format. Every saved secret keeps working, and the container log shows one Moved the installation key line.

If both files exist, startup stops without changing either one. Put the matching key at /config/keys/installation.key and remove the obsolete copy only after you have verified it. The database migration behaves the same way when both the old postgres/ and new database/ directories hold files: it stops rather than combining or overwriting them.

If the Key File Is Missing

When the key file is gone but the database holds secrets the old key encrypted, the next start makes a new key and removes those secrets. Everything else stays, including feature settings, accounts, passwords, passkeys, sessions, access tokens, and logs.

The appliance writes one credential_key_replaced warning to the container log that names each removed secret. The line never appears on the Logs page.

bash
docker logs discord-stonker-bot | grep credential_key_replaced
docker compose logs app | grep credential_key_replaced
The installation key line
text
2026-10-25T12:30:00.000Z WARN migration: credential_key_replaced message=No installation key was found at /config/keys/installation.key, so Stonker Bot for Discord made a new one. Enter the saved secrets again in the control panel.

Notification destinations that kept working, because they have no secret fields, also get a Saved secrets were removed alert with the same list, as described in Notifications.

When nothing depended on the old key, such as on a fresh install, there's no warning and no notice.

The Saved Secrets Notice

After a new key replaces a lost one, the control panel shows Saved secrets were removed at the top of every page, with the date the new key was made and a link for each removed secret.

Saved secrets were removed notice with the date the new key was made, links to Enter the Bot Token, Enter the Message copiers secrets for Stonker Lounge, Set up the Homelab alerts notification again, and Set up the Mod alerts notification again, and a Dismiss button
The saved secrets notice

Everyone sees the link for their own authenticator app. The Owner, Administrators, and Operators also see the Bot Token link, the notification links, and the feature links for the servers they can open, while Viewers see only their own.

If the Key File Belongs to Another Database

A key file that doesn't match the database, such as one from another install, stops startup instead. The appliance logs migration_failed with this error, and the bot, the control panel, and the worker don't start:

text
The installation key at /config/keys/installation.key doesn't belong to this database. Put back the key file this database was created with, or delete /config/keys/installation.key and restart to make a new key, then enter the saved secrets again.

Every start stops the same way until you put back the key file this database was created with. Deleting the key file instead makes a new one on the next start, as described in If the Key File Is Missing.

Back Up the Database

Run pg_dump inside the container and write a custom-format dump to the Docker host. It connects over PostgreSQL's Unix socket, so it needs no password.

docker run
bash
sudo docker exec --user 1000:1000 discord-stonker-bot sh -c \
  'pg_dump --host=/tmp/postgresql --username="${POSTGRES_USER:-stonker}" --dbname="${POSTGRES_DB:-stonker}" --format=custom' \
  > stonker.dump
Docker Compose
bash
docker compose exec --no-TTY --user "${PUID:-1000}:${PGID:-1000}" app sh -c \
  'pg_dump --host=/tmp/postgresql --username="${POSTGRES_USER:-stonker}" --dbname="${POSTGRES_DB:-stonker}" --format=custom' \
  > stonker.dump

With docker run, use your own PUID and PGID in place of 1000:1000.

It is recommended to store the dump away from the Docker host, keep a copy of the installation key with the same care as a password, and test a restore before you rely on it.

Restore From a Backup

A restore needs the database dump and the installation key from the same appliance.

A new container makes its own key on its first start, while a dump restored into it brings back the old database's key check. The next start then stops with the error in If the Key File Belongs to Another Database.

Network Storage

PostgreSQL expects the behavior of a local filesystem. It is recommended to keep the data volume on local disk and copy pg_dump backups to a NAS or other remote storage, instead of placing the live database on NFS or SMB.

Growth Over Time

The appliance never deletes old log entries or finished jobs, so the database grows as the bot runs. Invite page images are the exception: saving the invite page deletes the uploads it no longer uses.

Delete Everything

danger

docker compose down --volumes permanently deletes the database and the installation key.