RefLib

Reference library for AI

Back

postgresql_16:7.2.8.5 Examples

PostgreSQL 16 > Reference > PostgreSQL Client Applications > pg_basebackup > Examples

To create a base backup of the server at mydbserver and store it in the local directory /usr/local/pgsql/data: $ pg_basebackup -h mydbserver -D /usr/local/pgsql/data

To create a backup of the local server with one compressed tar file for each tablespace, and store it in the directory backup, showing a progress report while running: $ pg_basebackup -D backup -Ft -z -P

To create a backup of a single-tablespace local database and compress this with bzip2: $ pg_basebackup -D - -Ft -X fetch | bzip2 > backup.tar.bz2 (This command will fail if there are multiple tablespaces in the database.)

To create a backup of a local database where the tablespace in /opt/ts is relocated to ./backup/ts: $ pg_basebackup -D backup/data -T /opt/ts=$(pwd)/backup/ts

To create a backup of a local server with one tar file for each tablespace compressed with gzip at level 9, stored in the directory backup: $ pg_basebackup -D backup -Ft --compress=gzip:9

Back