How to do it...

For this procedure, we will need two servers. The backup server will be named pg-backup, and our primary PostgreSQL server will be named pg-primary. Make sure to have passwords for both the barman and postgres system users and the postgres database user. As usual, our database is located at /db/pgdata.

Follow these steps:

  1. Install the Barman toolkit as a root-capable user:
    • For Red Hat-based servers, use the following command: sudo yum install barman
    • Debian-based systems should use this command instead: sudo apt-get install barman
  2. On the pg-backup server as the barman user, execute the following commands for direct SSH access to pg-primary as the postgres user:
        ssh-keygen -t rsa -N ''
        ssh-copy-id postgres@pg-primary

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.