pg_basebackup -h 127.0.0.1 -U replicator -D /var/lib/postgresql/16/standby -X stream -P

Category: Databases & SQL

pg_basebackup -h 127.0.0.1 -U replicator -D /var/lib/postgresql/16/standby -X stream -P

Take a base backup for a standby

Copies the whole data directory from the primary with -X stream fetching WAL as it goes, the foundation of a streaming-replica setup. -P shows progress. The replicator role needs the replication privilege in pg_hba.conf.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.