CICD-313 · Database restoration
Encyclopedia · Database delivery and migration · All snippets
Previous · CICD-312 · Next · CICD-314
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
RESTORE_URL.
2. Copy the snippet
bash
pg_restore --exit-on-error --single-transaction --no-owner --no-privileges --dbname="${RESTORE_URL:?}" before-release.dump
psql "$RESTORE_URL" -X -v ON_ERROR_STOP=1 -f tests/restore-checks.sql3. How it works
The target is a fresh isolated database. Restore and SQL checks fail on errors and verify application-level invariants after loading the backup.
Restoring data requires verification against the isolated target.
flowchart TD N1["Backup archive"] N2["Restore disposable database"] N1 --> N2 N3["Run invariant queries"] N2 --> N3 N4["Expected data contract"] N4 --> N3 N5["Restore verdict"] N3 --> N5
4. Verify the result
Restore into a fresh isolated database and verify record counts or domain invariants.
Validation syntax-validated (Bash parse). Status definitions.