The following setup would enable Barman to backup the database using the pg_basebackup, and receive the WAL logs using the pg_receivewal, where Barman installed on the same OS as the PostgreSQL Database (No SSH/RSYNC):
1st. prepare the Global/General Configuration File (barman).
2nd. prepare the Server Configuration File( barman):
$ cat /etc/barman.d/{servername}.conf
[streaming] # the name of the server configuration file, which would be later refer to as {barman-server-config-name}
# Human readable description
description = "Main PostgreSQL 10 Database (Streaming-Only)"
# #########################################################
# PostgreSQL connection string (mandatory)
# #########################################################
conninfo = host=localhost user=barman dbname=postgres
# #########################################################
# PostgreSQL streaming connection string
# #########################################################
# To be used by pg_basebackup for backup and pg_receivexlog for WAL streaming
streaming_conninfo = host=localhost user=barman
# #########################################################
# Backup settings (via pg_basebackup)
# #########################################################
backup_method = postgres
# #########################################################
# WAL streaming settings (via pg_receivexlog)
# #########################################################
streaming_archiver = on
slot_name = barman
#streaming_archiver_name = barman_receive_wal
#streaming_archiver_batch_size = 50
# PATH setting for this server
#path_prefix = "/usr/pgsql-12/bin"
backup_method = postgres
incoming_wals_directory = /var/lib/barman/streaming/incoming
3rd. prepare the ~/.pgpass File:
$ cat ~/.pgpass
#hostname:port:database:username:password
localhost:5432:replication:barman:barman
localhost:5432:postgres:barman:barman
$ chmod 0600 ~/.pgpass
4th. prepare the PostgreSQL Database:
create the database user:
$ psql –c “create user barman superuser replication password 'barman';”
Edite the PostgreSQL configuration file /etc/postgresql/{major-realease}/{cluster-name}/postgresql.conf:
wal_level = replica
archive_mode = on
archive_command = 'test ! -f /var/lib/barman/{barman-server-config-name}/incoming/%f && cp %p /var/lib/barman/ {barman-server-config-name} /incoming/%f'
archive_timeout = 3600
max_wal_senders = 2
max_replication_slots = 10
Create Slot & Start the receive-wal process for Barman:
Start a receive-wal process. The process uses the streaming protocol to receive WAL files from the PostgreSQL server.
$ barman cron
$ barman receive-wal –create-slot {barman-server-config-name}
$ barman receive-wal {barman-server-config-name}
Check Server status & replication status:
$ barman check {barman-server-config-name}
$ barman status {barman-server-config-name}
$ barman replication-status {barman-server-config-name}