Back up and restore
At the end of this page, you know how to turn on the nightly backup, how to take a dump by hand, and what the restore status is.
Turn on the nightly backup
Section titled “Turn on the nightly backup”The backup runs in the backup profile. It writes encrypted dumps every night to the volume dmsforall_dfa_postgres_backups.
-
Put an
agepublic key in.env:Terminal window AGE_CLE_PUBLIQUE=age1... -
Start the profile:
Terminal window docker compose --profile backup up -d
Keep the age private key off this server. Without it, the backups cannot be read. The backup is built from the repository, so keep a clone of it on the server.
The backup hour is set with HEURE_SAUVEGARDE (default 03:15) and the time zone with DFA_TIMEZONE (default UTC).
Take a dump by hand
Section titled “Take a dump by hand”For a one-off copy of the database, use pg_dump in the Postgres container:
docker compose exec postgres pg_dump -U dfa -Fc dfa > dfa-$(date +%Y%m%d).dumpStore the file encrypted and outside the server.
What is not backed up
Section titled “What is not backed up”- The uploaded documents, in the volume
dmsforall_dfa_api_uploads. Check the backup scope before you rely on it. - The Redis data. Queues and short-lived state are recreated.
Restore
Section titled “Restore”A restore brings the database back to the time of the backup. Everything written after that backup is lost.
- Stop the
apiandworkerservices, so that nothing writes to the database. - Restore the dump into an empty database on a separate machine first, and check the result.
- Only then restore on the production server.