How to configure local-rsync on barman

Prince Nwando
Prince Nwando

Barman (Backup and Recovery Manager) is an open-source administration tool for disaster recovery of PostgreSQL servers written in Python; thereby allowing businesses to perform remote backups of multiple servers to reduce risk and help DBAs during the recovery phase. The aim of this article is to help understand the backup method called local-rsync and how to set this up on your barman server on a global/server stage.

Introducing the local-rsync feature in Barman

In version 2.12, Barman introduced a new backup_method option called local-rsync. This feature basically targets the cases where Barman is installed on the same server where PostgreSQL is. It directly uses rsync to take base backups, bypassing the SSH layer. However, this is not recommended in a production scenario to avoid a single point of failure

In that case, If the backup method is set to local-rsync, then barman will assume it to be running on the same server as the PostgreSQL instance and with the same user, then execute rsync for the file system copy.

That said, barman-cli provides the barman-wal-archive and barman-wal-restore commands - these are independent of the backup method and will still be useful with backup_method = local-rsync. Having said that, if local-rsync is being used because SSH on the localhost is not available, then those commands won’t work. Since they require SSH.

How to configure local-rsync

Ensure that you have the following prerequisites:

  • A PostgreSQL server running on the same machine as Barman.
  • Barman installed and configured on your system.
  • Run barman as the same user as postgres server.

Now to configure Barman to use local backup for a given server in Barman, you need to set backup_method to local-rsync. The feature is essentially identical to its rsync equivalent, which relies on SSH instead and operates remotely. With local-rsync file system copy is performed, issuing rsync commands locally (for this reason it is required that Barman runs with the same user as PostgreSQL). Set up your local-rsync on barman using the following steps:

  • Locate and edit your barman.conf file
  • Find the backup_method parameter and set it to local-rsync as shown below
[test server]
description = "test server"
backup_method = local-rsync
  • Save the changes and exit the text editor.
  • Rerun barman check

That’s it! You have successfully set up local-rsync on BARMAN. Setting this up will generally ensure that your data is backed up locally using rsync instead of SSH. Be sure to regularly verify your backups for integrity to ensure a smooth disaster recovery process.

Please note that if local-rsync is being used as a result of SSH not being available in the localhost, some other commands like barman-wal-archive and barman-wal-restore will not work in this environment. Those commands are independent of the backup method used and they still require SSH.

Was this article helpful?

0 out of 0 found this helpful