Skip to content

CICD-312 · Pre-deployment database backup ​

Encyclopedia · Database delivery and migration · All snippets

Previous · CICD-311 · Next · CICD-313

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites disposable database, migration tools and a scoped database role.
  • Platforms local-linux, github-actions, gitea-actions.
  • Parameters DATABASE_URL.

2. Copy the snippet ​

bash
umask 077
pg_dump --format=custom --file=before-release.dump "${DATABASE_URL:?}"
pg_restore --list before-release.dump > before-release.list
test -s before-release.list

3. How it works ​

pg_dump writes a custom-format archive and pg_restore --list inspects its catalog. A separate restore drill is required to demonstrate recoverability.

4. Verify the result ​

Secure backup storage and rehearse restore. A nonempty catalog alone does not prove data restore.

Validation syntax-validated (Bash parse). Status definitions.