Backup and recovery

PostgreSQL is the one and only permanent storage used for InfraBuffet data. Users, teams, credentials/settings, source files, templates, block values, jobs, and each scope’s Terraform state live there.

Back up

Keep database backups together with the matching application revision and deployment configuration. Protect archives as sensitive data: they can contain provider/source credentials, secret block values, and Terraform state.

For a custom-format database archive, using an already configured private database URL:

pg_dump --dbname="$IBF_DBURL" --format=custom --file=ibf.dump

Check the command’s exit status and diagnostics. pg_dump provides a consistent database snapshot, but that snapshot is not an atomic snapshot of external cloud resources. For a controlled recovery point, stop new submissions, let active apply/import jobs finish, then stop application processes before taking the final backup. Follow your PostgreSQL backup procedure for roles and other cluster objects.

Retain the process supervisor/proxy configuration, executable/tool versions, required certificates, and external secrets alongside the recovery procedure. Worker module/provider caches are rebuildable and do not replace stored data source files or state.

Restore into an isolated environment

  1. Stop web and worker processes. Create an empty destination database with the required role and permissions.
  2. Restore the archive, using a database URL for that destination:
pg_restore --dbname="$IBF_RESTORE_DBURL" --exit-on-error ibf.dump
  1. Start the matching application build against the restored database before considering an upgrade.
  2. Inspect restored jobs and locks before starting workers. A backup may contain queued or running operations; starting workers can execute queued work against real provider destinations.
  3. Verify users, source files, templates, blocks, and scope states. In a controlled scope, calculate a fresh diff and compare it with actual external resources before authorizing apply.

Use pg_restore’s reference for ownership and permission options when restoring into a different database environment.

State and external effects

Restoring a database does not roll back resources changed after the backup. An old state can disagree with provider reality. Reconcile deliberately; do not blindly apply every difference after restoration or discard state to make an error disappear.

Test the full restore procedure regularly, including credentials, worker executables, and source/provider access. A successful archive command is weaker evidence than a verified restore.