Theory
- The restore command automatically defaults to selecting the latest backup from the first repository where backups exist. The order in which the repositories are checked is dictated by the pgbackrest.conf (e.g. repo1 will be checked before repo2). To select from a specific repository, the --repo option can be passed (e.g. --repo=1). The --set option can be passed if a backup other than the latest is desired.
- Restoration Scenarios:
- Restoring the backup on a different host
- Restoring a single database from the Postgres cluster
- Restoring the backup to a specific point in time
- Restoring only the delta changes
- Restoring the backup on a different host to start as a streaming standby
1. Verify backup information
[enterprisedb@edb-nhatrang ~]$ pgbackrest info --stanza=employees
2. Restoring the backup on a different host (IP : 192.168.56.77)
- Setup Passwordless SSH Connection between Backup Server (192.168.56.79) and Database Server (192.168.56.77)
- Backup Server
- ssh-keygen -t rsa
- ssh-copy-id enterprisedb@192.168.56.77
- Database Server
- ssh-keygen -t rsa
- ssh-copy-id enterprisedb@192.168.56.79
- Database Server - Setup pgBackRest Repository
[root@edb-quynhon ~]# vi /etc/pgbackrest.conf
[global]
repo1-host=192.168.56.79
repo1-host-user=enterprisedb
log-level-console=info
log-level-file=debug
[employees]
pg1-path=/u01/edb/as16/data
pg1-database=edb
pg1-port=5444
pg-version-force=16
2.1 Database Server - Restore the Lastest Backup
[enterprisedb@edb-quynhon ~]$ pgbackrest --log-level-console=info --stanza=employees --process-max=2 restore
2024-06-25 15:47:07.509 P00 INFO: restore command begin 2.52: --exec-id=9675-76a8160f --log-level-console=info --log-level-file=debug --pg1-path=/u01/edb/as16/data --pg-version-force=16 --process-max=2 --repo1-host=192.168.56.79 --repo1-host-user=enterprisedb --stanza=employees
2024-06-25 15:47:08.481 P00 INFO: repo1: restore backup set 20240624-221733F_20240624-221842I, recovery will start at 2024-06-24 22:18:42
2024-06-25 15:47:17.598 P00 INFO: write updated /u01/edb/as16/data/postgresql.auto.conf
2024-06-25 15:47:17.625 P00 INFO: restore global/pg_control (performed last to ensure aborted restores cannot be started)
2024-06-25 15:47:17.628 P00 INFO: restore size = 740.5MB, file total = 2201
2024-06-25 15:47:17.628 P00 INFO: restore command end: completed successfully (10124ms)
==> The latest backup from the first repository will be restored