CertGrid CertGrid
Hands-on Lab·PostgreSQL

PostgreSQL Database Restore

The database is dropped for real - which first requires evicting every connection - and rebuilt from the dump. An untested backup is a guess; this is the test.

Backup and Restore Guide 22 of 47 Beginner

Written against the versions above. `DROP DATABASE` fails while any session is connected, including idle ones. `pg_terminate_backend` over `pg_stat_activity` is the standard way to clear them.

Every command on this page ran on db-a01.
Server NameIP AddressOSRolesCPURAMHDD
db-a01192.168.0.81Ubuntu 26.04 LTSPrimary / Source / Replica Set Member 12 Core4 GB50 GB

Before you start

  1. Evict the connections, then drop it

  2. Recreate and restore

  3. Verify against the numbers you wrote down

Official sources