Administration
Backups and restore
What to back up on a Postern Hub, how scheduled and manual backups work, how to restore (also onto a new machine or from the desktop app to a server), off-site copies and what backups mean for deleted accounts.
How you run the Hub
Commands on every page follow this choice.
This page has instructions for several ways of running the Hub. Each is shown under its name.
A Hub keeps everything in two places: the data directory and the master key file. This page shows how to back up both, how the Hub's automatic backups work, and how to restore them, on the same machine or a new one.
Your mail itself lives at your providers (Gmail, Outlook, your IMAP server). A Hub backup protects what only the Hub knows: accounts, mailbox sign-ins, settings, tags, Spaces, rules and their history, drafts, the send queue, and the Hub's copy of mail. A Hub restored without its mail copy downloads the mail again from the providers.
What to back up #
| Data directory | Master key | |
|---|---|---|
| Docker Compose | volume postern_postern-data, /data in the container |
volume postern_postern-key, /key/hub.key in the container |
| Debian, Fedora, Raspberry Pi OS | /var/lib/postern |
/var/lib/postern-key/hub.key |
| Desktop app (built-in Hub) | hub-data/ in the app's data folder |
hub-key/hub.key in the app's data folder |
The app's data folder is ~/Library/Application Support/Postern on macOS, %APPDATA%\Postern
on Windows and ~/.config/Postern on Linux.
Important
Back up both, and keep them apart. Everything sensitive in the data directory is encrypted
with keys that the master key unlocks. A backup without the key cannot be read by a thief, and
it cannot be read by you either. The Hub's backups never include the key file: copy it once,
to a different place (a password manager works well), and again after every rotate-key.
What a backup contains #
The Hub writes each backup as a folder named after the time it was made (UTC):
backups/
backup-20261205-033000/
hub.db consistent copy of the database
blobs/ encrypted message bodies, attachments and uploads
manifest.json format, Hub version, creation time, applied migrations, file counts
pre-migrate-20261201-101500.dbThe database copy is taken with SQLite's VACUUM INTO while the Hub runs, so it is consistent
without stopping anything. Files in blobs/ are hard-linked when the backup folder is on the same
file system as the data directory: they take no extra space, and seven backups do not use seven
times the disk. Blob files are never changed in place, so a hard link is a real copy of the
content as it was. On another file system they are copied.
Scheduled backups #
The Hub makes a backup on its own every 24 hours, and the first one 5 minutes after its first
start. It keeps the newest 7 and deletes older backup-* folders.
| Variable | Default | Meaning |
|---|---|---|
POSTERN_BACKUP_INTERVAL |
24h |
Time between backups, in Go duration syntax (12h, 168h). 0 turns scheduled backups off. |
POSTERN_BACKUP_KEEP |
7 |
How many backup-* folders to keep. At least 1. |
POSTERN_BACKUP_DIR |
<data-dir>/backups |
Where backups and pre-migrate-*.db copies go. |
After a restart the schedule continues from the newest backup in the folder. A failed backup
is logged as scheduled backup failed, and the admin panel warns when the newest backup is
older than twice the interval plus an hour.
To change these:
Docker Compose
Add the variables to ~/postern/compose.override.yaml. To keep backups outside the volume,
mount a host folder owned by the container's user (uid 10001):
services:
hub:
environment:
POSTERN_BACKUP_INTERVAL: 12h
POSTERN_BACKUP_KEEP: "14"
POSTERN_BACKUP_DIR: /backups
volumes:
- /srv/postern-backups:/backupssudo install -d -o 10001 -g 10001 -m 0700 /srv/postern-backups
cd ~/postern
docker compose up -dBlobs are copied, not hard-linked, into a folder on another file system, so each backup then takes the full size of the mail store.
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
Add the variables to /etc/postern/hub.env:
POSTERN_BACKUP_INTERVAL=12h
POSTERN_BACKUP_KEEP=14
POSTERN_BACKUP_DIR=/srv/postern-backupsThe service may only write to its own folders. For a backup folder elsewhere, create it and allow
it in a drop-in (sudo systemctl edit postern-hub):
sudo install -d -o postern -g postern -m 0700 /srv/postern-backups
sudo systemctl edit postern-hub[Service]
ReadWritePaths=/srv/postern-backupssudo systemctl restart postern-hubBlobs are copied, not hard-linked, into a folder on another file system.
Desktop app (built-in Hub)
The built-in Hub uses the defaults: a backup every 24 hours in hub-data/backups/, the newest 7
kept. They are only made while the app is open. They cannot be changed from the app. Your
computer's own backup (Time Machine, Windows File History) picks the folder up together with the
rest of the app's data folder, including hub-key/hub.key: see the note about keeping them apart
above.
Copies before an upgrade #
Before the Hub changes its database schema (on the first start after an upgrade), it writes
pre-migrate-<time>.db into the backup directory. This is a copy of the database only, without
blobs/, and it is never deleted automatically. Remove old ones yourself once the new
version runs well. They are what you restore when an upgrade goes wrong (see
Upgrades).
Make a backup now #
postern-hub backup writes a backup at once. It works while the Hub runs.
| Flag | Meaning |
|---|---|
| none | Write into POSTERN_BACKUP_DIR and delete the oldest so that POSTERN_BACKUP_KEEP remain. |
--out DIR |
Write into DIR instead (created if missing). Nothing is deleted. |
Docker Compose
cd ~/postern
docker compose exec hub postern-hub backup --out /data/backups/manualDebian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub backup --out /var/lib/postern/backups/manual'Desktop app (built-in Hub)
The desktop app has no command for this. Use the newest folder in hub-data/backups/, or quit
the app and copy hub-data/ as a whole.
✓ Backup written to /var/lib/postern/backups/manual/backup-20261205-153356 (957.0 KiB)
! The master key file /var/lib/postern-key/hub.key is NOT included. Back it up separately: without it the backup cannot be decrypted.Copy the key and a backup off the machine #
First the key (once, and after every key rotation):
Docker Compose
cd ~/postern
docker compose cp hub:/key/hub.key ./hub.key
chmod 600 hub.keyThe copy in ~/postern/hub.key belongs to you. Move it to your password manager or another
safe place, then delete it here.
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo install -m 0600 -o "$USER" /var/lib/postern-key/hub.key ~/hub.keyMove ~/hub.key to your password manager or another safe place, then delete it here.
Desktop app (built-in Hub)
Copy hub-key/hub.key from the app's data folder, for example on macOS:
cp ~/Library/Application\ Support/Postern/hub-key/hub.key ~/Desktop/postern-hub.keyStore the copy somewhere safe, away from your other backups.
Then a backup folder:
Docker Compose
cd ~/postern
docker compose exec hub ls /data/backups
docker compose cp hub:/data/backups/backup-20261205-033000 ./Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo ls /var/lib/postern/backups
sudo cp -a /var/lib/postern/backups/backup-20261205-033000 ~/
sudo chown -R "$USER": ~/backup-20261205-033000Desktop app (built-in Hub)
The folders are in hub-data/backups/ in the app's data folder. Copy one with your file manager.
Off-site copies #
Copy the backup directory to another machine regularly. Two examples, run as root on the Hub's machine. With restic to a NAS over SFTP:
Docker Compose
sudo restic -r sftp:backup@nas.example.com:/srv/restic/postern init
sudo restic -r sftp:backup@nas.example.com:/srv/restic/postern backup /var/lib/docker/volumes/postern_postern-data/_data/backups/var/lib/docker/volumes/... is where Docker keeps named volumes by default
(docker volume inspect postern_postern-data shows the path on your machine).
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo restic -r sftp:backup@nas.example.com:/srv/restic/postern init
sudo restic -r sftp:backup@nas.example.com:/srv/restic/postern backup /var/lib/postern/backupsDesktop app (built-in Hub)
Use your computer's backup tool for the app's data folder. If you want the Hub's backups on a
NAS, copy hub-data/backups/ there with the tool you already use.
Or with rsync. Use -H so the hard-linked blobs are copied once, not once per backup:
Docker Compose
sudo rsync -aH --delete /var/lib/docker/volumes/postern_postern-data/_data/backups/ backup@nas.example.com:/srv/postern-backups/Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo rsync -aH --delete /var/lib/postern/backups/ backup@nas.example.com:/srv/postern-backups/Desktop app (built-in Hub)
Not needed for most people: see above.
Run it from a daily cron job or systemd timer, some time after the Hub's own backup. Keep the key out of that destination, or the off-site copy alone is enough to read everything.
Restore #
Restoring replaces the Hub's database and blobs/ with those of a backup. The Hub must be
stopped. The command checks the backup's database first (backup database is damaged if not),
then moves the current database and blobs to <data-dir>/pre-restore-<time>/ instead of deleting
them. Remove that folder yourself once everything works.
| Flag | Meaning |
|---|---|
--from PATH |
A backup folder (backup-...), any folder with a hub.db and optionally blobs/, or a single .db file such as pre-migrate-....db. A single file restores only the database and leaves the current blobs/ in place. |
--yes |
Do not ask. Without it the command asks "Replace the Hub data in ... with ...? [y/N]" and stops without a terminal. |
The key file is not touched: the key in place must be the one that belongs to the backup.
Docker Compose
cd ~/postern
docker compose stop hub
docker compose run --rm hub restore --from /data/backups/backup-20261205-033000
docker compose start hubdocker compose run starts a one-off container with the same volumes. The image's entry point
is postern-hub, so restore ... are its arguments.
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo systemctl stop postern-hub
sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub restore --from /var/lib/postern/backups/backup-20261205-033000'
sudo systemctl start postern-hubDesktop app (built-in Hub)
There is no restore command in the app. Do by hand what restore does:
- Quit Postern completely (on macOS Postern → Quit Postern; on Windows and Linux also from the tray icon). The built-in Hub stops with it.
- In the app's data folder, open
hub-data/. Make a folderpre-restoreand movehub.db,hub.db-wal,hub.db-shm(if present) andblobsinto it. - Copy
hub.dband theblobsfolder from the backup folder (for examplebackups/backup-20261205-033000/) intohub-data/. - Start Postern.
On macOS or Linux:
cd ~/Library/Application\ Support/Postern/hub-data
mkdir pre-restore
mv hub.db* blobs pre-restore/
cp backups/backup-20261205-033000/hub.db .
cp -R backups/backup-20261205-033000/blobs .On Linux the folder is ~/.config/Postern/hub-data.
✓ Restored /data/backups/backup-20261205-033000
The previous database and blobs were kept in /data/pre-restore-20261205-154210
Make sure /key/hub.key is the key file that belongs to this backup.Check: run postern-hub doctor (Doctor). The Master key line must say
matches the database. Then sign in.
If it did not work: "the data directory is in use by a running Hub: stop the Hub before
restoring" means the Hub still runs. "does not look like a backup (no hub.db)" means --from
points at the wrong folder. If doctor says "does not match this database (cannot decrypt
...): wrong key file?", put the right key in place: a backup made before a rotate-key needs
the old key (hub.key.bak next to the current one).
After a restore, everything since the backup is gone from the Hub: accounts, devices, settings and rules changed since then. Devices that signed in after the backup have to sign in again. Mail catches up from the providers on its own.
Restore onto a new machine #
- Install the Hub on the new machine as in Set up your Hub, but do not open the setup wizard.
- Copy the key file and a backup folder to the new machine (for example with
scp). - Put both in place and restore:
Docker Compose
Start once so Compose creates the volumes, then stop the Hub and copy the key and the backup into
the volumes with a one-off container of the same image (run in the folder that holds hub.key and
the backup folder):
cd ~/postern
docker compose up -d
docker compose stop hub
cd ~
docker run --rm --user 0 --entrypoint sh -v postern_postern-key:/key -v "$PWD":/src:ro ghcr.io/theoriuhd/postern-hub:local -c 'cp /src/hub.key /key/hub.key && chown 10001:10001 /key/hub.key && chmod 600 /key/hub.key'
docker run --rm --user 0 --entrypoint sh -v postern_postern-data:/data -v "$PWD":/src:ro ghcr.io/theoriuhd/postern-hub:local -c 'mkdir -p /data/backups && cp -a /src/backup-20261205-033000 /data/backups/ && chown -R 10001:10001 /data/backups'
cd ~/postern
docker compose run --rm hub restore --from /data/backups/backup-20261205-033000 --yes
docker compose start hubThe first start created a new, empty database and a new key; the steps above replace both.
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo systemctl stop postern-hub
sudo install -d -o postern -g postern -m 0700 /var/lib/postern /var/lib/postern-key /var/lib/postern/backups
sudo install -o postern -g postern -m 0600 ~/hub.key /var/lib/postern-key/hub.key
sudo cp -a ~/backup-20261205-033000 /var/lib/postern/backups/
sudo chown -R postern:postern /var/lib/postern/backups
sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub restore --from /var/lib/postern/backups/backup-20261205-033000 --yes'
sudo systemctl start postern-hubDesktop app (built-in Hub)
To move the built-in Hub to another computer, install Postern there, start it once with Run a
Hub on this computer without setting it up, quit it, copy hub-key/hub.key over the new one
and restore as shown above.
- Set the same
POSTERN_PUBLIC_URLas before and point your DNS, proxy or Tailscale name at the new machine. If the address stays the same, devices reconnect on their own and passkeys keep working. If it changes, everyone signs in at the new address and adds new passkeys.
Move from the desktop app to a server #
The desktop app's built-in Hub is fine for trying Postern on one computer. To use your phone too, move it to a server:
- Set up the server as in Set up your Hub, without opening the setup wizard.
- On the computer, take the newest folder in
hub-data/backups/(check its date; anything changed after it stays behind) andhub-key/hub.keyfrom the app's data folder. - Copy both to the server and follow Restore onto a new machine.
- In the desktop app, connect to the server's address instead of the built-in Hub and sign in
with your usual email and password. Passkeys made for
localhostdo not work on the server: add new ones there.
Test a restore #
A backup you have never restored is a hope, not a backup. You can test one without touching the
running Hub, by restoring into a separate folder and pointing doctor at it:
Docker Compose
cd ~/postern
docker compose exec hub postern-hub restore --from /data/backups/backup-20261205-033000 --data-dir /data/restore-test --yes
docker compose exec hub postern-hub doctor --data-dir /data/restore-test
docker compose exec hub rm -rf /data/restore-testDebian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub restore --from /var/lib/postern/backups/backup-20261205-033000 --data-dir /var/lib/postern/restore-test --yes'
sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub doctor --data-dir /var/lib/postern/restore-test'
sudo rm -rf /var/lib/postern/restore-testDesktop app (built-in Hub)
Not available from the app. Test on a server instead, with a copy of the backup and the key.
The test needs as much free space as the backup (blobs are copied, not linked). In the doctor
output, look for integrity check passed under Database and matches the database under
Master key. Network warnings in the test are expected. Better still, once a year, restore onto
a spare machine and sign in.
Deleted accounts and the GDPR #
Deleting an account removes the person's data and their encryption key from the live Hub. It does not reach into backups:
- the scheduled backups still hold the account until they rotate out, which takes
POSTERN_BACKUP_KEEPtimesPOSTERN_BACKUP_INTERVAL(7 days by default); pre-migrate-*.dbcopies hold it until you delete them (they are never deleted automatically);pre-restore-*folders in the data directory hold it until you delete them;- your off-site copies hold it for as long as their own retention says.
Anyone with these and the master key can restore the account, including its mailbox sign-ins.
If you promise people that deletion is final, for example under the GDPR, write down how long
each copy lives, delete pre-migrate-*.db and pre-restore-* once an upgrade or restore went
well, and keep the off-site retention short enough to name.
If the key is lost #
Without the key file nothing encrypted can be read: not the mailbox sign-ins, not the stored mail, not the Google client secret. There is no recovery. Your mail is still safe at your providers: start a new Hub with a fresh data directory and new key, then have everyone connect their mailboxes again.
To change the key on purpose (for example if it was exposed), use postern-hub rotate-key. See
Encryption.