infra/scripts/backup.sh, restore.sh, restore-drill.sh), not as a managed
backup service. This page states what those scripts do today, plainly,
including the gaps: a number nobody would act on if it turned out to be
wrong is worse than no number at all.
What is backed up
PostgreSQL, including roles and privileges. Apg_dump of the schema and
its data, plus a separate pg_dumpall --roles-only of the cluster’s login
roles. Both matter: the application connects as narrow, non-superuser roles
(trustowl_app_login, trustowl_job_login) that row-level security binds,
and those roles are cluster objects a plain database dump does not carry.
Restoring the data without them produces a database RLS does not enforce, or
one every query is refused against. See
Data protection for why the role matters this
much.
Encrypted on the host that took it, to an age recipient you supply in
BACKUP_PUBLIC_KEY: that host then holds no key that can decrypt its own
backups. Without a key the script refuses to run and writes nothing. A
plaintext backup is still possible, but only by writing
BACKUP_ALLOW_UNENCRYPTED=true in the env file, so it is a recorded decision
rather than what happens when a variable is left unset. Redis is
not backed up. It holds queue state and rate-limit counters, both
reconstructable, never a customer’s security findings.
What is not backed up, or not yet proven
- Off-host storage has been drilled only against a local
rclonetarget, not a real S3-compatible bucket with production credentials. Until that drill runs against real object storage, treat the off-host copy as configured but unproven in your environment. The remote isBACKUP_REMOTE; the rclone configuration that defines it can be named withBACKUP_RCLONE_CONFIG(one file per stack, mode 600), so the bucket credential is not whichever user’s~/.configa timer runs as. - The
agedecryption identity’s storage location is an operator decision, documented as needing to live off the production host. Nothing in the software enforces that placement. Verify it in your own deployment. - The Kubernetes / managed-Postgres deployment path has no backup gate
wired into it today. The Compose deployment path does; a managed Postgres
provider’s own backup and PITR features are the appropriate substitute if
you deploy that way, and are not something TRUSTIVAN configures for you.
The
hetzneroverlay, which runs Postgres in the cluster, carries a nightly encrypted dump to object storage instead (Kubernetes); it has been restored from on a local cluster only, and nothing alerts when a run fails.
RPO and RTO, as shipped
Neither number has been validated against production traffic or production
infrastructure: both are measured against a local drill. Treat them as
engineering targets you re-verify in your own environment, not as an SLA.
Point-in-time recovery
The production Compose file turns on WAL archiving: PostgreSQL copies every finished WAL segment, compressed, into the stack’swal_archive volume.
infra/scripts/pitr.sh does the rest, with PostgreSQL’s own tools only
(pg_basebackup, pg_archivecleanup, restore_command):
Install the timers with
infra/scripts/routines.sh enable <stack>, which also
schedules the nightly dump and the audit checkpoints;
infra/scripts/routines.sh check reports what is and is not scheduled. Until
the PITR timer runs, the archive only grows: nothing else deletes from it.
infra/scripts/test-pitr.sh, run by make ci-deployment, proves the path
against the compose file’s own PostgreSQL service: rows committed before a
chosen moment come back and rows after it do not. The off-host copy has been
exercised only for its refusal to run without an encryption key; restoring
from it is not drilled.
The restore drill, and what it proves
restore-drill.sh fetches the newest backup from the off-host copy (or, with
--local, from BACKUP_DIR), starts a throwaway PostgreSQL (a separate
Compose project, <stack>-drill, running only the postgres service on a fresh
volume, with none of the live cluster’s roles), restores into it through
restore.sh, and removes it again on every exit. Nothing is restored into the
live cluster. It then checks, in order:
- Row counts match the backup. Every table’s rows in the dump’s data section against the same table in the restored database.
- The migration version matches the backup, and is not dirty. The live database’s version and the checkout’s newest migration are printed beside it, so a backup older than the code is visible.
tenant_isolationpolicies exist on the restored tables.- Per-role grants exist for both the application and job-plane roles, because a restore that carries the data and the policies but not the privileges produces a database that refuses every query, which looks identical to “the restore worked” until the first request.
backup.sh dump: PASS — restored into a fresh PostgreSQL; 406744 rows and migration 163 match the backup, in about 20 seconds. The same drill on a
truncated copy of that backup failed and recorded
trustowl_restore_drill_success 0.
A weekly timer (trustivan-restore-drill@<stack>.timer, installed by you and
only useful once BACKUP_REMOTE is set) runs it and writes a dated artefact: “we have backups” is a
belief; a file recording that a restore from off-host storage completed on a
given date, with the checks it passed, is evidence. See
Audit trail for the parallel principle applied to
the identity trail.
Retention
Local backups (encrypted.dump.age / .roles.sql.age files, or plaintext
dumps on a host that set BACKUP_ALLOW_UNENCRYPTED=true) are pruned after
BACKUP_RETENTION_DAYS (default 30; 0 turns pruning off). Off-host
retention is not currently governed by this tooling. Set a lifecycle rule on
whatever object storage you configure.
Settings the scripts read
None of these is read by the API or the worker. The scripts take each from the process environment first, and otherwise from the deployment’s environment file,infra/docker/.env unless ENV_FILE names another.
Keep
BACKUP_IDENTITY_FILE off the host that takes the backups. A host that
holds both the encrypted dumps and the identity that opens them has gained
nothing from encrypting them.
See also
- Data map: what is stored, encrypted or not, and for how long, independent of backups.
- Production Compose: the environment file these settings live in.