Barman
Barman isn’t primarily used as a performance-oriented backup tool, but as a centralized and compliant archiving solution. While pgBackRest provides parallel, incremental, and high-speed backups for operational recovery, Barman focuses on long-term WAL archiving and disaster recovery compliance. It continuously streams WAL segments from multiple PostgreSQL clusters into a single offsite location, ensuring point-in-time recovery capability and meeting financial audit and data retention regulations. In large FinTech or banking infrastructures, Barman acts as a second layer of protection — slower, but more reliable and auditable.
To install and demostrate:
# on each PostgreSQL (post1, post2, post3)
sudo dnf install -y barman-cli
patronictl -c /etc/patroni/postgres.yml edit-config ibo-cluster
wal_level: replica
archive_mode: ‘on’
archive_command: ‘barman-wal-archive 169.254.23.27 ibo-cluster %p’
max_wal_senders: 16
max_replication_slots: 10
or
patronictl -c /etc/patroni/postgres.yml set-config ibo-cluster \
-s postgresql.parameters.wal_level=replica \
-s postgresql.parameters.archive_mode=on \
-s postgresql.parameters.archive_command=’barman-wal-archive 169.254.23.27 ibo-cluster %p’ \
-s postgresql.parameters.max_wal_senders=16 \
-s postgresql.parameters.max_replication_slots=10
— pg_hba.conf
host replication barman 169.254.23.27/32 md5
host all barman 169.254.23.27/32 md5
patronictl -c /etc/patroni/postgres.yml reload ibo-cluster
patronictl -c /etc/patroni/postgres.yml show-config ibo-cluster | grep wal
archive_command: barman-wal-archive 169.254.23.27 ibo-cluster %p
max_wal_senders: 16
wal_level: replica
psql -U postgres -c “CREATE ROLE barman WITH REPLICATION LOGIN PASSWORD ‘barman’;”
# Barman sunucusunda (169.254.23.27)
sudo dnf install -y barman
sudo mkdir -p /etc/barman.d
sudo chown -R barman:barman /etc/barman.d /var/lib/barman /var/log/barman
Barman sunucusunun (169.254.23.27) konfigürasyonuna geçiyoruz.
Bu aşamada 2 dosya oluşturacağız:
/etc/barman.conf → genel ayarlar
sudo tee /etc/barman.conf >/dev/null <<’EOF’
[barman]
barman_user = barman
barman_home = /var/lib/barman
configuration_files_directory = /etc/barman.d
log_file = /var/log/barman/barman.log
compression = gzip
retention_policy = REDUNDANCY 3
EOF
/etc/barman.d/ibo-cluster.conf
sudo tee /etc/barman.d/ibo-cluster.conf >/dev/null <<’EOF’
[ibo-cluster]
description = Patroni HA Cluster via VIP
conninfo = host=169.254.23.20 user=barman dbname=postgres password=barman port=5000
backup_method = postgres
streaming_archiver = on
slot_name = barman_slot
streaming_conninfo = host=169.254.23.20 user=barman dbname=postgres password=barman port=5000
EOF
Barman’ın barman-wal-archive kullanabilmesi için ssh erişimi gerekli.
Bunu sadece Barman sunucusunda yap:
Get Ibrahim Guler’s stories in your inbox
Join Medium for free to get updates from this writer.
su — barman
ssh-keygen -t rsa
ssh-copy-id postgres@169.254.23.10
ssh-copy-id postgres@169.254.23.11
ssh-copy-id postgres@169.254.23.12
exit
[barman@barman ~]$ sudo -u barman barman receive-wal — create-slot ibo-cluster
Creating physical replication slot ‘barman_slot’ on server ‘ibo-cluster’
Replication slot ‘barman_slot’ created
[postgres@post1 ~]$ psql “host=169.254.23.20 dbname=postgres user=barman password=barman port=5000 replication=database”
psql (17.6)
Type “help” for help.
postgres=# IDENTIFY_SYSTEM;
systemid | timeline | xlogpos | dbname
— — — — — — — — — — -+ — — — — — + — — — — — -+ — — — — —
7555142464643063007 | 5 | 0/D000130 | postgres
(1 row)
[root@barman ~]# sudo -u barman which pg_receivewal
which: no pg_receivewal in (/sbin:/bin:/usr/sbin:/usr/bin)
[root@barman ~]# sudo -u barman barman receive-wal ibo-cluster
Starting receive-wal for server ibo-cluster
ERROR: ArchiverFailure:pg_receivewal not present in $PATH
[root@barman ~]# sudo ln -s /usr/pgsql-17/bin/pg_receivewal /usr/bin/pg_receivewal
[root@barman ~]# ls -l /usr/bin/pg_receivewal
lrwxrwxrwx 1 root root 31 Oct 18 22:33 /usr/bin/pg_receivewal -> /usr/pgsql-17/bin/pg_receivewal
[root@barman ~]# sudo -u barman which pg_receivewal
/bin/pg_receivewal
[root@barman ~]# sudo -u barman barman receive-wal ibo-cluster
Starting receive-wal for server ibo-cluster
ibo-cluster: pg_receivewal: starting log streaming at 0/D000000 (timeline 5)
[root@barman ~]# sudo -u barman barman check ibo-cluster | grep -E “PostgreSQL|streaming|slot|WAL”
PostgreSQL: OK
PostgreSQL streaming: OK
replication slot: OK
[root@barman ~]# sudo -u barman barman backup ibo-cluster
[root@barman ibo-cluster]# sudo -u barman barman list-backup ibo-cluster
ibo-cluster 20251018T224038 — F — STARTED
Starting backup using postgres method for server ibo-cluster in /var/lib/barman/ibo-cluster/base/20251018T230758
Backup start at LSN: 0/F000130 (00000005000000000000000F, 00000130)
Starting backup copy via pg_basebackup for 20251018T230758
Copy done (time: 13 minutes, 40 seconds)
Finalising the backup.
This is the first backup for server ibo-cluster
WAL segments preceding the current backup have been found:
00000005000000000000000E from server ibo-cluster has been removed
00000005000000000000000F from server ibo-cluster has been removed
Backup size: 8.5 GiB
Backup end at LSN: 0/12000060 (000000050000000000000012, 00000060)
Backup completed (start time: 2025–10–18 23:07:58.850432, elapsed time: 13 minutes, 44 seconds)
WARNING: IMPORTANT: this backup is classified as WAITING_FOR_WALS, meaning that Barman has not received yet all the required WAL files for the backup consistency.
This is a common behaviour in concurrent backup scenarios, and Barman automatically set the backup as DONE once all the required WAL files have been archived.
Hint: execute the backup command with ‘ — wait’
postgres=# SELECT pg_switch_wal();
pg_switch_wal
— — — — — — — -
0/15000148
(1 row)
postgres=#
postgres=# SELECT pg_switch_wal();
pg_switch_wal
— — — — — — — -
0/16000078
(1 row)
[root@barman ~]# sudo -u barman ls -lh /var/lib/barman/ibo-cluster/streaming
total 48M
-rw — — — — 1 barman barman 16M Oct 18 23:49 000000050000000000000015
postgres=# SELECT pg_switch_wal();
pg_switch_wal
— — — — — — — -
0/17000000
(1 row)
[root@barman ~]# sudo -u barman ls -lh /var/lib/barman/ibo-cluster/streaming
-rw — — — — 1 barman barman 16M Oct 18 23:49 000000050000000000000015
-rw — — — — 1 barman barman 16M Oct 18 23:49 000000050000000000000016
postgres=# SELECT pg_switch_wal();
pg_switch_wal
— — — — — — — -
0/17000078
(1 row)
[root@barman ~]# sudo -u barman ls -lh /var/lib/barman/ibo-cluster/streaming
total 48M
-rw — — — — 1 barman barman 16M Oct 18 23:49 000000050000000000000015
-rw — — — — 1 barman barman 16M Oct 18 23:49 000000050000000000000016
-rw — — — — 1 barman barman 16M Oct 18 23:49 000000050000000000000017
sudo -u barman barman recover ibo-cluster 20251018T230758 /var/lib/barman/restore_test — target-time “2025–10–18 23:15:00”






