Reading preferences
Concept

Backups and Recovery Verification

Distinguish an archive from a tested recovery process.

database, postgresql, backup, recovery, pg-dump, restore

An archive is not a recovery plan

A backup protects against failures a transaction rollback cannot fix, such as an already committed mistake or loss of the database. A recovery plan also defines the acceptable data-loss window and recovery time, protects backup access, and regularly verifies that restoration works.

SQL illustration

Assume an authorised disposable source database contains a persistent table training.books with four fictional rows, and its archive has been restored into an isolated test database. One possible check there is:

SELECT COUNT(*) AS book_count FROM training.books;

Prepared result for that specific fixture:

book_count
4

A count alone does not establish that all rows, constraints, permissions, or application behaviour are correct. The earlier lesson's temporary tables are session-scoped and are not a backup fixture. Verify restored contents against appropriate expectations and exercise relevant application checks.

See the reasoning

Follow the example one step at a time

Follow a backup toward a tested recovery, not just an archive listing. This is a prepared teaching demonstration, not live code execution.

Create an archive

training_db → pg_dump → training.dump
logical backup of one database

A successful dump creates an archive, but global objects and external systems need separate consideration.

From archive to verified restore

These are illustrative commands for an authorised disposable PostgreSQL environment, not operations performed by Intuvo:

pg_dump --format=custom --file=training.dump training_db
pg_restore --list training.dump
pg_restore --exit-on-error --dbname=restore_test training.dump

The first command creates a logical archive of one database. The second lists archive entries; it does not test a complete restore. The third restores into an already prepared, isolated empty test database and stops on error. Stopping on error does not undo earlier restored objects; the target may be partially restored. Never point a restore at production by accident; it can create or change objects. Check credentials, destination, disk space, ownership and version compatibility before an authorised test. Credentials do not belong in command lines, examples, or logs.

pg_dump does not include cluster-wide roles and tablespaces; plan separately for required global objects, extensions, configuration, and external systems. Physical backups with archived WAL can support point-in-time recovery when properly configured; a logical dump alone is not that recovery system. Encrypt and protect backups appropriately, monitor jobs, and practice full recovery against the actual recovery objectives.

Reflect on the concept

Four fixed questions to reinforce the reasoning. Answers are not saved or scored.

1. What does a successful pg_dump of a database provide?
2. Does listing an archive prove a complete restore will succeed?
3. Where should a recovery test run?
4. Are backups and transactions interchangeable?

References and further reading