May 22, 2021

pg_basebackup PostgreSQL tool

PostgreSQL pg_basebackup utility


pg_basebackup # used to take base backup of running PostgreSQL database cluster
pg_basebackup --help
pg_basebackup --version

pg_basebackup -h localhost -p 5454 -D /data/postgres/12/5454
pg_basebackup --host localhost --pgdata /usr/postgres/backups -U postgres

pg_basebackup -Fp -D - | gzip > ~/backup.tar.gz
pg_basebackup -Ft -D /data/postgres/9.6/5311
pg_basebackup -U postgres -D /data/backup/12 -Ft -z -P -Xs

pg_basebackup --help

Usage:
  pg_basebackup [OPTION]...

Options controlling the output:
  -D, --pgdata=DIRECTORY receive base backup into directory
  -F, --format=p|t        output format (plain (default), tar)
  -r, --max-rate=RATE    maximum transfer rate to transfer data directory (in kB/s, or use suffix "k" or "M")
  -R, --write-recovery-conf write configuration for replication
  -t, --target=TARGET[:DETAIL]    backup target (if other than client)
  -T, --tablespace-mapping=OLDDIR=NEWDIR  relocate tablespace in OLDDIR to NEWDIR
      --waldir=WALDIR    location for the write-ahead log directory
  -X, --wal-method=none|fetch|stream include required WAL files with specified method
  -z, --gzip              compress tar output
  -Z, --compress=[{client|server}-]METHOD[:DETAIL] compress on client or server as specified
  -Z, --compress=none    do not compress tar output

General options:
  -c, --checkpoint=fast|spread set fast or spread checkpointing
  -C, --create-slot      create replication slot
  -l, --label=LABEL      set backup label
  -n, --no-clean          do not clean up after errors
  -N, --no-sync          do not wait for changes to be written safely to disk
  -P, --progress          show progress information
  -S, --slot=SLOTNAME    replication slot to use
  -v, --verbose          output verbose messages
  -V, --version          output version information, then exit
      --manifest-checksums=SHA{224,256,384,512}|CRC32C|NONE use algorithm for manifest checksums
      --manifest-force-encode hex encode all file names in manifest
      --no-estimate-size do not estimate backup size in server side
      --no-manifest      suppress generation of backup manifest
      --no-slot          prevent creation of temporary replication slot
      --no-verify-checksums do not verify checksums
  -?, --help              show this help, then exit

Connection options:
  -d, --dbname=CONNSTR    connection string
  -h, --host=HOSTNAME    database server host or socket directory
  -p, --port=PORT        database server port number
  -s, --status-interval=INTERVAL time between status packets sent to server (in seconds)
  -U, --username=NAME    connect as specified database user
  -w, --no-password      never prompt for password
  -W, --password          force password prompt (should happen automatically)


Related Postgres Articles: PostgreSQL pg_dump utility

No comments:

Post a Comment