Backups and restore
Everything Day Planner stores (accounts, tasks, documents, settings) is in its Postgres database. Back that up and you can rebuild the whole instance.
Make a backup
Section titled “Make a backup”This saves a compressed dump named with the current time.
docker compose exec -T db pg_dump -U dayplanner -d day_planner -Fc \ > day_planner-$(date -u +%Y%m%dT%H%M%SZ).dumpCheck the file starts with PGDMP, the custom-format header:
head -c 5 day_planner-*.dumpCopy backups off the server. Run this from cron for regular backups.
Test a backup
Section titled “Test a backup”A backup that’s never been restored isn’t a backup. This restores into a throwaway container and counts users:
docker run -d --name dp-restore -e POSTGRES_PASSWORD=restore -e POSTGRES_DB=day_planner postgres:16-alpinesleep 5docker cp day_planner-<timestamp>.dump dp-restore:/tmp/b.dumpdocker exec dp-restore pg_restore -U postgres -d day_planner --no-owner --no-acl /tmp/b.dumpdocker exec dp-restore psql -U postgres -d day_planner -Atc "select count(*) from users"docker rm -f dp-restoreCompare the count, and those for tasks and documents, with the live database.
Restore
Section titled “Restore”Restoring replaces the live data. Take a fresh backup first, and stop the app so nothing writes during the restore.
docker compose stop appdocker compose cp day_planner-<timestamp>.dump db:/tmp/b.dumpdocker compose exec db pg_restore -U dayplanner -d day_planner --clean --if-exists --no-owner --no-acl /tmp/b.dumpdocker compose start appWhen the app starts, it applies any migrations the backup is missing.
See also
Section titled “See also”- Upgrading: back up before every upgrade
- Migration failed: recovering from a failed upgrade