Skip to content

Backups

Everything Shardlens stores is in PostgreSQL. Back it up with pg_dump, keep .env safe separately, and test a restore now and then.

From the folder with docker-compose.yml:

Terminal window
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:

Terminal window
0 3 * * * cd /opt/shardlens && docker compose exec -T postgres pg_dump -U shardlens -Fc shardlens > backups/shardlens-$(date +\%F).dump

Copy the dumps off the server and encrypt them; a backup holds hashed user IDs and, in audit mode, encrypted identities.

  1. Stop the collector so nothing writes during the restore:

    Terminal window
    docker compose stop collector
  2. Restore into a clean database:

    Terminal window
    docker compose exec -T postgres dropdb -U shardlens shardlens
    docker compose exec -T postgres createdb -U shardlens shardlens
    docker compose exec -T postgres pg_restore -U shardlens -d shardlens < shardlens-2026-11-13.dump
  3. Start the collector with the same .env:

    Terminal window
    docker compose start collector

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.

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.