Use Case 2: Running pgBackRest from a Dedicated Repository Host
Suggest editsDescription
- pgBackRest runs on a dedicated backup server and stores repository on local or remote storage (NFS, S3, Azure or GCS compatible object stores).
- Cron task active to take backups from the primary database cluster.
- Manually reconfigure cron task to take backup from another server.
Create a Dedicated User on the Repository Host
The pgbackrest
user is created to own the backups and archives repository. Any user can own the repository, but it is recommended not to use postgres
or enterprisedb
to avoid confusion.
Setup Passwordless SSH Connection
pgBackRest requires a passwordless SSH connection to enable communication between the hosts.
The following example SSH commands should succeed without prompting you for a password:
Configuration
Backup Server
The repository should be reachable from the backup server. It can be located on the various supported types described in the first use case.
For example, let us create /backup_space
to store our backups and archives locally:
The [global]
section of the configuration file will look like this:
Adjust the encryption passphrase and the maximum number of processes to use for compression usage and file transfer.
See the Recommended settings pages for more details.
The [demo]
stanza section will contain specific pg-
options for each database node.
- the primary database server configuration for PostgreSQL
or for EDB Postgres Advanced Server
- for every other PostgreSQL node
or for EDB Postgres Advanced Server
Define multiple nodes using pg2
, pg3
,... to reach standby servers only when those servers are available.
Database server(s)
Update the pgBackRest configuration file on the database server(s):
The [demo]
stanza section will be different for PostgreSQL or for EDB Postgres Advanced Server, and the recovery-option
is used to set the replication primary_conninfo
after executing the restore command. For more details, please refer to the Use case 1 page for more details.
Setup Archiving
Once pgBackRest is configured, set up the database archiver process on each node:
As changing the archive_mode
parameter requires a service restart, and changing the archive_command
only requires a configuration reload, we recommend enabling archive_mode
with an empty archive_command
(or pointing to /bin/true) when initiating a new database cluster.
From the backup server (also called repository host), initiate the pgBackRest repository with the system user we created earlier:
Check the configuration and the archiving process:
Backup and Restore
See the Quick start backups and restore sections for more details about those two commands.
The backup
command will be executed on the repository host (aka. backup-server), while the restore
command should be executed on database nodes (aka. postgres-node-1,...).
Glossary
pgBackRest
delta
log-level-console
log-level-file
pg-host
pg-path
pg-port
pg-user
process-max
recovery-option
repo-cipher-pass
repo-cipher-type
repo-host
repo-host-user
repo-path
repo-retention-full
start-fast
PostgreSQL
Could this page be better? Report a problem or suggest an addition!