postgres backup pg_rman - ghdrako/doc_snipets GitHub Wiki
- https://www.postgresql.org/docs/current/backup.html
- pg_rman -phiscal backup + pitr
- pg_basebackup
- pg_dump - logical backup
- pg_backrest
- barman
Physical backup
rsync
rsync is a widely used utility for efficiently synchronizing files and directories between different locations. It can be utilized for physical backups by copying the PostgreSQL data directory to a backup location. The basic rsync command for backing up a PostgreSQL data directory would be: rsync -avz -- progress /path/to/pg/data/ /path/to/bkp/location/ This command re cursively copies the files and directories from the PostgreSQL data directory to the backup location while preserving file permissions, ownership, and timestamps.
Systemctl stop postgresql-15.service
rsync -avz –progress /var/lib/pgsql/15/data /pg_backup/Physical_bkp
The command initiates the rsync utility.
-a
enables the archive mode, which preserves file attributes such as permissions, ownership, and timestamps.-v
activates verbose mode, providing detailed information about the files being copied.-z
enables compression during the transfer to reduce network bandwidth usage.--progress displays
the progress of the backup process, showing the transfer rate and estimated completion time./var/lib/pgsql/15/data
represents the source directory where the PostgreSQL data files are located. You may need to adjust the path based on your PostgreSQL installation./pg_backup/Physical_bkp
is the destination directory where the backup files will be stored. Modify the path according to your desired backup location.
pg_basebackup
A built-in tool provided by PostgreSQL for taking base backups at the file level. It performs a streaming backup of the entire database cluster, including data files and transaction logs. To use pg_basebackup, you would typically execute a command like.
pg_basebackup -D /path/to/bkp/location -Ft -X stream This command instructs pg_base
backup to stream the backup in the tar format (-Ft) to the specified backup location (-D). The -X stream option ensures that the backup is streamed rather than written to a file on the server.
pg_basebackup -U postgres -D /pg_backup/phy_bkp -Ft -z -P -Xs -c fast