Introduction
Having a strong backup and recovery strategy is crucial for any organization that relies on Postgres as its database management system, and pgBackRest plays a vital role in ensuring the safety and integrity of data. With pgBackRest, organizations can establish a robust backup process that provides peace of mind and minimizes the risk of data loss. By implementing regular backups, organizations can recover from various incidents, such as hardware failures, software glitches, or human errors. Additionally, pgBackRest offers features like incremental backups, parallel compression, and backup integrity checks, enhancing the efficiency and reliability of the backup and recovery process. In the event of a disaster or data corruption, a well-planned backup and recovery strategy with pgBackRest allows organizations to quickly restore their Postgres databases, minimize downtime, and safeguard critical information. Investing in a strong backup and recovery strategy is an essential aspect of maintaining data continuity, meeting regulatory requirements, and ensuring business continuity in the face of unforeseen challenges.
As discussed on the Postgres Backup for Peeps blog, here are the basic steps to install and configure pgBackRest for backing up a production PostgreSQL server:
PgBackRest Installation:[root@localhost ~]# yum install pgbackrest
[root@localhost ~]# pgbackrest version
pgBackRest 2.45
Change Parameters on postgresql.conf
[postgres@localhost ~]$ cd /var/lib/pgsql/15/data/
[postgres@localhost data]$ vi postgresql.conf
wal_level = replica
max_wal_senders = 10
hot_standby = on
archive_mode = on
archive_command = 'pgbackrest --stanza=12_data archive_push %p'
:wq!
Restart PostgreSQL to enable the change to the parameters.systemctl restart postgresql-12
Change Parameters on pgbackrest.conf
bash-5.1$ vi /etc/pgbackrest.conf
[global]
repo1-path=/var/lib/pgbackrest
log-level-console=info
log-level-file=debug
[main]
pg1-path=/var/lib/pgsql/15/data
[postgres@localhost ~]$ pgbackrest stanza-create --stanza=main --log-level-console=info
NFO: stanza-create command end: completed successfully (830ms)
[postgres@localhost ~]$ pgbackrest check --stanza=main --log-level-console=info
bash-5.1$ pgbackrest backup --stanza=main --log-level-console=info
bash-5.1$ pgbackrest info
Perform incremental backup:bash-5.1$pgbackrest backup --stanza=main --type=incr --log-level-console=info
Perform differential backup:bash-5.1$ pgbackrest --stanza=main --type=diff backup
Perform Restoration using pgBackrest :
Stop the server for restoration[postgres@localhost ~]$ systemctl stop postgresql-15.service
Restoring a Backup from a backup Repository[postgres@localhost ~]$ pgbackrest restore --stanza=test --delta
Leave a Reply