Post

Verify and scope manual media PostgreSQL restores for reliable rollback

Verify and scope manual media PostgreSQL restores for reliable rollback

The latest push adds verification to the manual media PostgreSQL restore flow so each restore uses a verified backup set and a stable operation ID, preventing stale NFS copies and data loss during rollback.

Implementation: verify and scope manual media PostgreSQL restores

I updated docs/rollback-argocd-apps.md with a new “Media PostgreSQL logical recovery” section that tells operators to select a BACKUP_ID from a successful backup Job, confirm the local claim can retain the previous data directory, and check that the digests for globals.sql and the six application dump files are valid before restoring and before promoting the restored data. The Job uses a stable operation ID for retries and a separate backup ID for provenance, keeps the previous directory, and records the completed operation on the target claim. I also added a sentence to openwiki/architecture/storage-and-state.md stating that the active recovery procedure uses a stable operation ID for retries and a separate backup ID for provenance, and that the Job verifies all seven backup members before restoring and before promoting its restored data directory.

Verification: offline test suite for media PostgreSQL recovery

I added scripts/ci/media-postgres-recovery-test.py, a new test module that runs the rendered manual restore against a local PostgreSQL 14 fixture data set. The test sets up BACKUP and OPERATION IDs, defines the database and file list, locates the PostgreSQL 14 directory, and executes the restore steps. I have not executed the test yet, so verification is pending; the next check is to run the offline test suite to confirm it correctly validates the restore process.

Platform engineering impact: scoped restore with verified backup sets

The scoped restore technique can be reused by any platform team that needs reliable manual database restores. By binding the restore to a verified backup set, using stable operation IDs, and keeping the previous data directory until promotion succeeds, teams reduce the risk of data loss when rolling back applications on Kubernetes.

Lessons learned: testing and tooling

Adding a dedicated test file improves confidence that the restore steps work end‑to‑end, and the offline checks script now runs that test, enabling early detection of failures. Merging the test code with the production scripts keeps the verification logic in sync with the implementation.

This post is licensed under CC BY 4.0 by the author.