PostgreSQL data-service track
From your Crucible Linux workspace, first create the example's environment using its locked dependencies, then run the script through that environment: The script chooses free ports, creates private directories, generates fixture passwords and starts clusters named.
Audience: operator who understands SQL transactions and the API/worker exercise. Prerequisites: native PostgreSQL client/server utilities on PATH, age, and the reference Python environment. Environment: two owned temporary clusters bound to loopback, using synthetic data. Expected outcome: prove that committed application state and identity survive a database process restart and an encrypted logical restore. Consult proof/postgres-recovery.json after your live VM verification run; this procedure does not imply a remote deployment.
Adapt all twelve phases
| Phase | Data-service decision and evidence |
|---|---|
| 1 Framework | Classify source of truth, logical databases, schemas, owners and consumers. |
| 2 Beginner | Explain committed rows, transactions, constraints, indexes, roles and connections. |
| 3 Architecture | Define consistency, write rate, data growth, recovery-point and recovery-time objectives. |
| 4 Provision | Separate durable storage, cluster initialization, network exposure and application rollout. |
| 5 Foundation | Restrict DB network access; distinguish migration owner, runtime role and backup identity. |
| 6 Service | Apply versioned schema, tune bounded connections/timeouts, test tenant queries and constraints. |
| 7 Go live | Validate application connectivity and representative transaction behavior with runtime privileges. |
| 8 Operate | Monitor free space, connections, query latency, locks, long transactions, backups and restore freshness. |
| 9 Change | Test indexes, schema changes, extensions and version upgrades with representative data and lock measurements. |
| 10 Recover | Restore independently, verify behavior/permissions and measure recovered point and usable service time. |
| 11 Migrate/retire | Control writers, reconcile final changes, verify consumers moved, then retain/revoke/delete per policy. |
| 12 Assess | Another operator restores without access to the old host and explains the actual loss window. |
Execute the isolated reference drill
From your VM workspace directory (~/playground), first create the example's environment using its locked dependencies, then run the script through that environment:
The script chooses free ports, creates private directories, generates fixture passwords and starts clusters named primary/recovery in its owned workspace. It migrates the primary database, seeds a tenant credential, completes a job, checks that the runtime role cannot create a table, restarts PostgreSQL and reads the result again. It then encrypts a custom-format dump with a generated age recipient, decrypts it, compares digests, restores into the second cluster and validates the result through the application. A corrupted ciphertext must fail decryption. Cleanup stops only the clusters the script created and removes their temporary state.
Expected output is a JSON receipt whose checks are true. A nonzero exit is a failure, even if a dump file existed. Capture the command exit and receipt; never replace a failed receipt with a stale prior run result. Missing executables, port conflicts and incompatible tools require resolving the actual environment problem, not weakening the assertions.
Understand the restoration contract
A logical dump is a consistent database snapshot, not a recording of every subsequent change. Custom-format archives are consumed by pg_restore. A standalone database dump does not carry every cluster-wide identity or external object; restore roles and permissions deliberately. The fixture uses --no-owner --no-acl and recreates the required application access in its controlled environment; a production procedure must explicitly handle ownership/grants. See [PostgreSQL SQL dump](https://www.postgresql.org/docs/current/backup-dump.html) and [pg_restore](https://www.postgresql.org/docs/current/app-pgrestore.html).
For production recovery, first identify the last verified backup, source version, extensions, encoding, ownership mapping and key location. Restore to a clean separate target; avoid --clean against an existing production database. Trust the backup's source and inspect untrusted archives: restore can execute database code contained in the archive. Keep external dispatchers disabled until side effects have been reconciled.
Count checks alone are insufficient. Verify primary keys, representative values, constraints, runtime permissions, latest expected business timestamp and an authenticated application transaction. Record the gap between the last required committed event and the recovered event as the observed loss window. Measure usable service recovery from the agreed start event, including access to artifacts, credentials, keys and network routing.
Advance beyond this fixture
The drill does not test continuous WAL archiving, point-in-time recovery, replicas, failover fencing, cross-region loss or a lost Mac. Add these only after defining the required contract. A replica can reproduce an accidental delete and does not replace retained backups. A failover design must prevent two primaries accepting conflicting writes. A physical backup's compatibility assumptions differ from a logical dump.
For performance, gather slow-query evidence and plans before adding indexes or replicas. Record pool limits across every API/worker replica so total connections stay bounded. Test long transactions and lock waits in staging. Monitor vacuum progress, dead tuples and storage growth according to the selected PostgreSQL version and workload; a generic tuning number is not a substitute for measurement.
A migration has a cutover point. Pause or fence writes, take the final consistent transfer, validate the destination, switch clients and observe errors and data consistency. Define whether rollback is still possible after the destination accepts writes. Retirement requires application-consumer confirmation, independent retained backups and revoked old connection identities before deleting the exact database/storage resources.
Lock in what you just learned (3 quick questions)
idle in transaction sessions stay open on a write-heavy table?EXPLAIN (ANALYZE, BUFFERS) after adding an index?