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
- OSUbuntu 26.04 LTS (resolute)
- PostgreSQL18.6-0ubuntu0.26.04.1
- wal_levelreplica
- TimeAbout 14 min
- Reviewed27 August 2026
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.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- The dump from the previous guide.
- A server you are willing to destroy.
-
Evict the connections, then drop it
-
Recreate and restore
-
Verify against the numbers you wrote down