Backups
What to back up on the control plane and the hosts, and how to restore the database.
Back up the database and .env together, and the object storage bucket with your store's own tools. Host disks are not a backup target.
Know what to back up
| What | Where | Losing it |
|---|---|---|
| The database | Docker volume pgdata | Everything: accounts, sandboxes, templates, keys |
| Settings and secrets | infra/compose/.env | Stored secrets become unreadable, signed snapshots invalid |
| Object storage | Docker volume s3data (bundled), or your bucket | All stored templates, snapshots and volumes |
| Pinned host certificates | Docker volume cpstate | Every host is unschedulable until it re-registers |
| TLS certificates | Docker volume caddy_data | Re-issued on start, within Let's Encrypt rate limits |
| Host settings | /etc/platinum/host.env on each host | Re-enroll the host |
With the bundled store, all stored sandbox data lives on the control plane machine. Replicate s3data off the machine, or use an external bucket.
Dump the database
# on the control plane, in platinum/infra/compose
docker compose exec -T postgres pg_dump -U platinum -Fc platinum > platinum-$(date +%F).dump
cp .env env-$(date +%F).backupRun it on a schedule, for example from cron, and copy each dump off the machine.
Check a dump
docker compose exec -T postgres pg_restore --list < platinum-DATE.dump | headRestore the database
Restore into the stack before the server starts.
# on the control plane, in platinum/infra/compose
docker compose up -d postgres
docker compose exec -T postgres pg_restore -U platinum -d platinum --clean --if-exists < platinum-DATE.dump
docker compose up -ddocker compose up -d runs migrate, which brings an older dump up to the running version's schema.
The database now describes the install as it was at dump time. Sandboxes created or deleted since then do not match what the hosts hold.
Back up the bucket
Use your store's replication or versioning, or any S3 sync tool. Do not use lifecycle rules: see Object storage.
Protect sandbox data
With object storage connected, snapshots and volumes keep sandbox data off the host. See Snapshots and Volumes.