3.4. Using pg_probackup3 in the Remote Mode #

pg_probackup3 supports operations in the remote mode. The backup data can be obtained from a remote Postgres Pro server using the built-in replication protocol. Backups can be saved to an S3 storage or to an SSH server via the SFTP protocol.

Depending on the type of operation you can choose the following scenarios:

  • To connect to the Postgres Pro server to create a backup, use the standard connection options: --pghost, --pgport, --pgdatabase, and --pguser.

  • To save, restore, and validate backups in an S3 storage, use the S3 options. Refer to Section 2.12 for more details.

  • To manage backups on an SSH server via the SFTP protocol, use the SSH options. Refer to Section 2.11 for more details.

This way, both the backup catalog and the Postgres Pro instance to back up can be located on remote servers.

The typical workflow is as follows:

  • On your backup host, configure pg_probackup3 as explained in the section Installation and Setup. For the init, add-instance, backup, and set-config commands, make sure to specify the connection options to the server with the Postgres Pro instance, as well as the the options to access the storage where the backups will be saved.

  • If you would like to rely on ARCHIVE WAL delivery mode, configure continuous WAL archiving from the database host as explained in the section Setting up continuous WAL archiving. For the archive-push command, specify the SSH options that point to the backup host with the backup catalog.

Note

To use the continuous WAL archiving mode, the pg_probackup3 executable files must be located on the Postgres Pro server. The Postgres Pro server calls pg_probackup3 with the archive-push and archive-get commands in accordance with the archive_command and restore_command parameters in its configuration.

For example, to create a local archive full backup of a Postgres Pro cluster located on a remote system with the host address 192.168.0.2 on behalf of the postgres user through the port 2302, run:

pg_probackup3 backup -B backup_dir --instance=instance_name -b FULL --pguser=postgres --pghost=192.168.0.2 --pgport=2302

To create a backup on an SSH server with the address 10.0.3.77 for the ubuntu user, run:

pg_probackup3 backup -B backup_dir --instance=instance_name -b FULL --pguser=postgres --pghost=192.168.0.2 --pgport=2302 --remote-host=10.0.3.77 --remote-user=ubuntu

The script for creating a backup in an S3 storage is as follows:

export PG_PROBACKUP_S3_PORT=9000
export PG_PROBACKUP_S3_ACCESS_KEY=admin
export PG_PROBACKUP_S3_SECRET_ACCESS_KEY=password
export PG_PROBACKUP_S3_REGION=us-west-2
export PG_PROBACKUP_S3_HOST=10.0.3.77
export PG_PROBACKUP_S3_BUCKET_NAME=test
pg_probackup3 backup -B backup_dir --instance=instance_name -b FULL --pguser=postgres --pghost=192.168.0.2 --pgport=2302 --s3

To set up continuous WAL archiving to an SSH server with the address 10.0.3.77, run the following command:

pg_probackup3 archive-push -B backup_dir --instance=instance_name --wal-file-name=%f --compress-algorithm=zstd --remote-host=10.0.3.77 --remote-user=ubuntu

To set up continuous WAL archiving to an S3 storage, run the following command:

pg_probackup3 archive-push -B backup_dir --instance=instance_name --compress-algorithm=zstd --wal-file-name=%f --s3 --config-file=s3.config

The connection options must be saved in the s3.config file in the Postgres Pro data directory.