4.7 KiB
Backup and restore
Principle
A backup is not considered valid until it is internally verified, and the backup system is not considered production-ready until a clean-target restore is tested.
Backup contents
A full backup set contains:
- PostgreSQL logical dump in a supported restorable format.
- Attachment blobs.
- Optional generated exports required by policy.
- Application configuration manifest without secrets.
- Product, schema and container/image versions.
- File inventory with sizes and SHA-256 hashes.
- Backup job metadata and timestamps.
- Encryption metadata when operator-managed encryption is enabled.
Do not include runtime session secrets or plaintext API tokens.
Consistency strategy
Preferred v1 approach:
- create a PostgreSQL consistent logical dump;
- snapshot/copy immutable content-addressed attachment blobs;
- capture attachment metadata and blob manifest from the same defined backup window;
- validate that every active DB blob reference exists in the manifest;
- record files added after the cutoff for the next backup.
Because committed blobs are immutable, exact transaction coordination is simpler than for mutable files. Deletions use retention, preventing a blob from disappearing during backup.
Backup workflow
- Acquire a backup job/lease.
- Record application/schema version and cutoff.
- Run PostgreSQL dump with failure-on-error.
- Inventory referenced attachment hashes.
- copy/link/archive required blobs without following unsafe paths;
- create manifest;
- verify dump readability and every file hash;
- optionally encrypt with an operator-supplied mechanism;
- atomically publish completed backup;
- apply retention only after a verified new backup exists;
- record audit and administrator-visible result.
A failed backup never replaces the last known-good backup.
Retention defaults
Configurable starting policy:
- 7 daily;
- 4 weekly;
- 6 monthly;
- at least one manually protected backup.
Retention must account for available storage and never delete an in-progress restore source.
Restore workflow
Restore is deliberately separate from normal application startup.
- Select backup.
- Verify manifest, hashes, version compatibility and encryption.
- Create clean PostgreSQL database and empty target directories.
- Restore database.
- Restore attachment blobs by hash.
- Start the recorded/current compatible application in maintenance mode.
- Apply supported migrations.
- Run integrity checks:
- FK/schema;
- user/membership;
- page/revision counts;
- current content hashes;
- link counts;
- project counts;
- attachment references vs blobs;
- import/audit consistency.
- Run authenticated smoke tests.
- Produce restore report.
- Promote target only through an explicit operator step.
Never test restore by overwriting the only production instance.
Backup encryption
The application may integrate an operator-supplied encryption command or library after threat review. Requirements:
- key is not stored only inside the backup;
- command arguments do not expose secrets in process listings where avoidable;
- restore can verify authentication/integrity before extraction;
- failure is explicit;
- documentation includes key-loss consequences.
Unencrypted backups must be clearly labeled and protected by host/storage controls.
Disaster recovery targets
Initial targets, to be confirmed on real hardware:
- RPO: last successful scheduled daily backup by default.
- RTO: documented single-host restore, target under 2 hours for typical personal dataset, excluding transfer of very large attachments.
Do not claim an RTO until a measured production-like rehearsal exists.
Tests
Trusted-intake pilot recovery
Before enabling intake, capture a verified backup and restore it into an isolated,
empty target. Record the source commit, image digest, migration range, backup ID,
table counts and attachment hashes. A rollback of intake starts by setting
IngestionProposal:Enabled=false and revoking the separate client's service
account. Keep proposals, source references, attachment usages and audit history;
disabling the feature is not a retention-cleanup instruction. Published attachments
remain referenced by their pages. Restore a pre-release backup only after an
isolated restore proves it is necessary and the operator has assessed newer writes.
- create backup with representative data;
- verify manifest;
- corrupt dump and blob tests;
- clean-target restore;
- compare logical counts and hashes;
- restore older supported schema then migrate;
- missing key/encrypted backup failure;
- interrupted backup cleanup;
- retention policy;
- no secret inclusion;
- large attachment set.