For administrators
← All topics

Backup and restore

What to back up besides the database, why MASTER_KEY matters just as much, and how to test a restore.

In an installation on your own server, everything that matters is in the database: settings, instructions, knowledge sources, messages, drafts and the encrypted secrets. So you back up the database — and MASTER_KEY.

What to back up

  1. The database — with a regular dump.
  2. MASTER_KEY from the .env file — once, off the server. Without it you cannot read the API keys, mailbox access or sign-in clients from the database; the backup would be useless.
  3. Optionally the whole .env (database passwords and other secrets) — in an equally safe place.

A database dump contains the customers' mail. Protect it like the mailbox itself.

Dumping the database

From the installation's directory:

mkdir -p data/backups
docker compose exec -T db mariadb-dump -udraften -p"$DB_PASSWORD" --single-transaction draften | gzip > data/backups/draften-$(date +%F).sql.gz

Run it regularly (daily from cron, say) and copy the dumps off the server.

Restoring

Into an empty database:

gunzip -c dump.sql.gz | docker compose exec -T db mariadb -udraften -p"$DB_PASSWORD" draften

Then start the installation with the same MASTER_KEY that applied at the time of the backup.

Watch out

Plain text version