CertGrid CertGrid
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

-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.

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

This guide includes

Use this when a logical dump is not enough. This matters because pg_basebackup copies the whole cluster over the replication protocol while it is running - which is what a replica, or a point-in-time restore, starts from.

Before you start

  1. Take a physical backup of the running cluster

  2. Look at what it produced

Official sources