0% found this document useful (0 votes)
72 views

Install pgbackrest and configure

This document provides a step-by-step guide for installing and configuring pgBackRest for PostgreSQL backups, including setting parameters in configuration files, creating a backup stanza, and performing full and incremental backups. It also outlines the process for restoring backups on another server and expiring old backups. The instructions include necessary commands and configurations for both backup and restore operations.

Uploaded by

kwakutse20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Install pgbackrest and configure

This document provides a step-by-step guide for installing and configuring pgBackRest for PostgreSQL backups, including setting parameters in configuration files, creating a backup stanza, and performing full and incremental backups. It also outlines the process for restoring backups on another server and expiring old backups. The instructions include necessary commands and configurations for both backup and restore operations.

Uploaded by

kwakutse20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Install pgbackrest
yum install pgbackrest

2. Next, verify pgBackRest was installed correctly by running the following command
either as the default user, or as the postgres user:
pgbackrest

3. configure below parameters in Postgresql.conf file and restart postgres

listen_addresses = '*'
archive_mode = on
archive_command = 'pgbackrest --stanza=main archive-push %p'

4. configure the below parameters in the /etc/pgbackrest.conf file and restart


postgres

[global]
repo1-path=/pg-db-backup/bkp
repo1-retention-full=2
repo1-retention-diff=2
log-level-console=info
#log-level-file=debug
start-fast=y
process-max=2
archive-timeout=300

[main]
pg1-path=/data/pgdata/data

5. create stanza for the main backup repository,

sudo -u postgres pgbackrest --stanza=main stanza-create

6. check that pgbackrest and archive_command are correctly configured

sudo -iu postgres pgbackrest --stanza=main check

7. perform a full backup

sudo -u postgres pgbackrest --stanza=main --compress-level=6 --type=full backup

8. And finally, confirm the backup is working:

sudo -u postgres pgbackrest info

9. perform incremental backup

sudo -u postgres pgbackrest --stanza=main --compress-level=6 --type=incr backup

10. Check progress of backup

sudo -u postgres pgbackrest info


RESTORE BACKUP ON TO ANOTHER SERVER
--------------------------------------

1. install pgbackrest on the server

yum install pgbackrest

2. configure the below parameters in /etc/pgbackrest.conf

[global]
repo1-path=/pg-db-backup/bkp
repo1-host=192.168.251.143
repo1-host-user=postgres
[main]
pg1-path=/data/pgdata/data

3. create the tablespace directories on the other server

4. configure passworless ssh for postgres user between spare server and primary

5. stop the postgres database and delete postgres datafiles it the exist

systemctl stop postgres


cd /data/pgdata/data
rm -rf *

6. start the restore

pgbackrest --config=/etc/pgbackrest.conf --log-level-console=info --stanza=main


restore

Restore with Incremental


===========================
pgbackrest --config=/etc/pgbackrest.conf --log-level-console=info --stanza=main --
target-timeline=current restore

expire backups
====================
sudo -u postgres pgbackrest --stanza=main --repo1-retention-full=1 expire

startup postgres and login

systemctl start postgresql

You might also like