Hands-on Lab·PostgreSQL
PostgreSQL Physical Backups with pg_basebackup
A physical copy of the entire cluster taken over the replication protocol while it runs - every database, every role, ready to start as a server. It is also the first half of both point-in-time recovery and a streaming replica.
Backup and Restore Guide 24 of 47 Intermediate
- OSUbuntu 26.04 LTS (resolute)
- PostgreSQL18.6-0ubuntu0.26.04.1
- wal_levelreplica
- TimeAbout 15 min
- Reviewed27 August 2026
Written against the versions above. `-Xs` streams WAL during the backup on a second connection, which is why the result is self-consistent without needing archived WAL to start. It requires a spare `max_wal_senders` slot.
| 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
- A superuser or a role with
REPLICATION. - Disk space for a full copy of the cluster.
-
Take a physical backup of the running cluster
-
Look at what it produced