Backups
Everything Shardlens stores is in PostgreSQL. Back it up with pg_dump, keep .env safe separately, and test a
restore now and then.
Daily backup
Section titled “Daily backup”From the folder with docker-compose.yml:
docker compose exec -T postgres pg_dump -U shardlens -Fc shardlens > "shardlens-$(date +%F).dump"Run it from cron, for example every night at 03:00:
0 3 * * * cd /opt/shardlens && docker compose exec -T postgres pg_dump -U shardlens -Fc shardlens > backups/shardlens-$(date +\%F).dumpCopy the dumps off the server and encrypt them; a backup holds hashed user IDs and, in audit mode, encrypted identities.
Restore
Section titled “Restore”-
Stop the collector so nothing writes during the restore:
Terminal window docker compose stop collector -
Restore into a clean database:
Terminal window docker compose exec -T postgres dropdb -U shardlens shardlensdocker compose exec -T postgres createdb -U shardlens shardlensdocker compose exec -T postgres pg_restore -U shardlens -d shardlens < shardlens-2026-11-13.dump -
Start the collector with the same
.env:Terminal window docker compose start collector
Test your restores
Section titled “Test your restores”Once a month, restore the latest dump into a scratch PostgreSQL container and open the dashboard against it. A backup you have never restored is a hope, not a backup.
Privacy and backups
Section titled “Privacy and backups”Erasure and salt destruction delete data from the live database, not from old backups. Keep backups only as long as you need them (for example 30 days), so erased data and destroyed salts age out of them too.