How to do it...

For this procedure, we will need one new server. The backup server will remain pg-backup, but we need a target server for the restore. This server will be named pg-clone. Make sure to have the password for the postgres system user on this server. As usual, our database will be located at /db/pgdata:

  1. On the pg-backup server as the barman user, execute the following command for direct SSH access to pg-clone as the postgres user:
        ssh-copy-id postgres@pg-clone
  1. Ensure that the target restore directory is empty on pg-clone with this command executed as the postgres user:
        rm -Rf /db/pgdata
  1. Transmit the backup to pg-clone by running this command as barman on the pg-backup server:
 barman recover --remote-ssh-command "ssh ...

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.