Overview

Barman is a backup & Recovery configuration which uses pg_basebackup and pg_receivexlog underneath in order to provide backup and restore functionalities. Furthermore, barman is able to operate on many servers, thus providing central location for backups for the entire infrastructure. At the same time, barman doesn't have a client application, the server installation is the only installation which has to be done. Even though there isn't client configuration, barman still has to be configured on both:

Target Machine

Barman Machine

Let's start with the Barman machine.

Barman Machine Configuration

The machine isn't mandatory to be with high specs, but at the same time, shouldn't be also a leftover :). The basic configuration of the barman is already provided through RPM as follows:

Library installation

Let's install firstly the libraries and thus the app:

After we have downloaded the main library, we can simply install barman using yum with little interference :).

Server Configuration

The configuration is practically within the /etc/barman.conf, however it took my VERY LONG time to figure out the exact one :).

As written above, the configuration file is structured in two areas:

Barman Configuration

Database Server Configuration

In order for the configuration above to work, there are several things which has to be done:

Configure passwordless configuration between barman(barman machine) and postgres(postgreSQL machine). Meaning that the barman user should be able to login, without password to the postgres user on he PostgreSQL. In order to do that, you have to:

Make sure your barman user' public key is in the authorized_keys file on the remote machine (postgres user)

Ensure your permissions are for the current user only in the home and .ssh directories (ie 700 or 644)

Ensure your sshd config allows key authentication

Configuration Separation

You can also separate the configuration of the databases, by splitting the configurations as follows:

Put all Barman config in /etc/barman.conf

Put each database config in /etc/barman.d/config_name.conf

You have to of course point that in the /etc/barman.conf as follows:

With this we set the configuration for the utility and with this:

We set up a configuration for the target database machine.

Client Machine

On the client machine there are 4+ things which we have to configure:

The PostgreSQL utilities(pg_receivexlog)

A PostgreSQL user: barman

Access to this machine via pg_hba.conf

Assure that we have at least +2 more wal_senders

Configuration

PostgreSQL Utilities

Utilities can be stalwartly installed via the YUM:

User Creation

User creation is rather simple in PostgreSQL, however since barman will be able to provide replication, he should have a super user rights as follows:

Access to the Machine

Access to the machine is granted via the pg_hba.conf file. In order to grant access to the PostgreSQL machine, use the following syntax:

pg_hba.conf

PLEASE KEEP IN MIND THAT THIS IS VERY UNSECURE METHOD (Hint. Trust) FEEL FREE TO CHANGE IT TO MD5 or OTHER.

Wal_senders

The wal_senders settings is in the postgresql.conf file and can easily be changed:

Barman In Action

Once everything is set up, you are ready to do your first backup using barman. From the barman server, issue the following command from the barman user:

Once you do the backup you can issue a check to see how is the server:

You see here that we fail to provide redundancy (we have only 1 backup) So I did one more :)

Backup to OCI

I had a task to backup using barman, encrypt, upload and house keep the backups. So I implemented a crontab, that do just that:

Backup script

The script is used very simple:

bash script.sh “dev”