Barman is a backup and recovery manager for PostgreSQL that provides centralized management of multiple servers. In this tutorial, we will cover how to install Barman on Alpine Linux.
Before installing Barman, let's update and upgrade the packages installed on the system.
sudo apk update
sudo apk upgrade
Barman requires several dependencies to be installed on your system before running it. We will install them using the following command.
sudo apk add python3-dev libffi-dev openssl-dev gcc musl-dev py3-pip
You can install Barman using pip3 package manager.
sudo pip3 install barman
Barman needs access to your PostgreSQL database, we need to configure PostgreSQL for Barman. Open the pg_hba.conf
file and add the following line at the end.
host all barman <ip_address>/32 trust
Replace <ip_address>
with the IP address of your Barman server.
In this step, we will configure Barman for our PostgreSQL database.
/usr/local/lib/python3.8/site-packages/barman/pgbarm.conf.sample
to /etc/barman.conf
sudo cp /usr/local/lib/python3.8/site-packages/barman/pgbarm.conf.sample /etc/barman.conf
sudo nano /etc/barman.conf
[barman]
barman_user = barman
barman_home = /var/lib/barman
backup_directory = /var/lib/barman/%s/backups
compression = gzip
minimum_redundancy = 1
retention_policy = RECOVERY WINDOW OF 30 DAYS
In this step, we will add our PostgreSQL database server to Barman.
pg1.conf
in the /etc/barman.d
directory.sudo nano /etc/barman.d/pg1.conf
[pg1]
description = "Production PostgreSQL server"
conninfo = host=<ip_address> user=<user> dbname=<dbname> password=<password>
backup_method = postgres
streaming_archiver = on
Replace <ip_address>
, <user>
, <dbname>
, and <password>
with your PostgreSQL server details.
In this step, we will take a backup of our PostgreSQL server using Barman.
sudo barman backup pg1
This command will create a new backup of the PostgreSQL server and save it in the Barman server's default backup directory.
Congratulations! You have successfully installed and configured Barman on Alpine Linux latest. You can now use it to manage your backups and recover PostgreSQL databases in case of any disaster or data loss.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!