Backups and restore

Everything that matters is the PostgreSQL volume, the SeaweedFS volume and your .env. One script copies all three, tests the copy in a throwaway database, and reports to Admin > Status.

Back up

Run the scripts from the folder with docker-compose.yml and .env (how to get the scripts):

BACKUP_DIR=/srv/backups/mnema ./scripts/backup.sh

This writes database, media, env and the compose file into BACKUP_DIR/<timestamp>/, with a manifest, SHA-256 checksums and a COMPLETE marker written after validation.

By default the backup is cold: the script stops the app and then SeaweedFS for the snapshot, so active calls disconnect for that moment, and resumes only the services that were running before. A backup contains .env with every secret: keep it safe, copy it off the machine, and encrypt offsite copies.

The restore test runs every time

After the services are back, backup.sh imports the dump into a throwaway, network-isolated PostgreSQL container and removes it again; the live database is never touched. A failed test keeps the backup, prunes nothing and makes the script exit non-zero, so cron reports it. RESTORE_TEST=0 skips the test (not recommended).

It then writes backup-status/status.json next to the deployment. The bundled compose file mounts that folder into the app, so Admin > Status > Backups & disaster recovery shows the age and size of the last backup and the restore test, and warns when the backup is older than 36 hours or the test failed.

Every night

A cron job on the host, for example at 03:30:

30 3 * * * cd /path/to/mnema-talk && BACKUP_DIR=/srv/backups/mnema ./scripts/backup.sh

Retention removes only validated, complete old backups after a successful run.

Online backups: no downtime

BACKUP_MODE=online BACKUP_DIR=/srv/backups/mnema ./scripts/backup.sh

The app keeps running: messages, presence and calls continue. Only the file storage is paused while its volume is copied, so uploads and downloads wait that long (seconds on a small server). The script takes a lock so file-deleting jobs wait, freezes storage, fixes one database snapshot, copies the storage and lets it continue, then dumps exactly that snapshot. The restore test reads every file the database refers to, so each online backup is proven complete.

Encrypted backups

With one or more age public keys in BACKUP_AGE_RECIPIENT (and age installed on the host), the finished, tested backup is packed into one <timestamp>.tar.age file and the plain folder is removed. Keep the private key away from the server:

age-keygen -o mnema-backup.keyBACKUP_AGE_RECIPIENT=age1... BACKUP_DIR=/srv/backups/mnema ./scripts/backup.sh

Run age-keygen on another machine; it prints the public key.

Restore

Check a backup first, then restore it:

./scripts/restore.sh /srv/backups/mnema/20261005-033000 --verify./scripts/restore.sh /srv/backups/mnema/20261005-033000

--verify imports into a disposable PostgreSQL container and checks the archives without touching anything live. The plain restore asks first (--yes skips the question), stops the writers, replaces database and media, and resumes the services that were running. For an encrypted backup, add the key only for the restore: BACKUP_AGE_IDENTITY=/root/mnema-backup.key ./scripts/restore.sh <file>.tar.age --verify.

Restore keeps the current .env and compose files. Compare them with the backed-up env by hand; blindly replacing database credentials or storage endpoints can lock you out of the restored data.

Moving to another machine

A backup and a restore: set up the new machine with the same .env, start PostgreSQL and SeaweedFS, restore, start the app, then move the DNS record. Every option, the online mode in detail and moving PostgreSQL between major versions: Backups and restore.

Something wrong on this page? Tell us.