-1

I'm trying to configure Barman (pgbarman) to work alongside the PostgreSQL database on the same host, i don't want to install barman on a separated host, but I can't find any documentation about such approach. All of the resources on the internet are about setting up barman on a separated server, then configure a SSH connection for WAL archiving and backups, do i need to setup a ssh connection also when i'm on the same host, when 'YES', then how to configure the Barman and the Database ?!

what i did is as following to achieve what i want (partially):

  • The Barman server configuration:
$ cat /etc/barman.d/10-main.conf

[10pg]
description =  "The main PostgreSQL server"
conninfo = host=127.0.0.1 user=barman dbname=postgres port=5432
backup_method = postgres
archiver=on
  • PostgreSQL Wal configuration (postgresql.conf):

I had to add the "chown" command because it barman doesm't recognize the files (WAL), if their ownership belong to another user (other than barman)

wal_level = replica
archive_mode = on 
archive_command = 'test ! -f /var/lib/barman/10pg/incoming/%f && cp %p /var/lib/barman/10pg/incoming/%f && sudo chown barman /var/lib/barman/10pg/incoming/%f'
  • PostgreSQL HBA (pg_hba.conf):
local   all             barman                                  peer
  • sudo without password for "postgres" user (/etc/sudoers):
postgres ALL=(ALL) NOPASSWD:ALL

as you can see, the above method doesn't look healthy.

icy3
  • 1
  • Thanks for your replay, I'm trying to mimic the oracle approach, typically the backup manager is part of the database software installation on the same server just to ease the backup and recovery operations. What would be the case then, if i don't have a separated device designated for barman, how would i use it then? Answering your question, i'm using barman to create a full backup of the database cluster and to stream the WAL logs into a backup file system. – icy3 Oct 06 '19 at 22:05
  • it's really doesn't matter if the barman software was on the same server or on a separated one, what count is the Data itself, where you store the data, so as long as the Data is secured on a separated file system, the software doesn't matter where it is installed, plus in my case, i can't setup password-less ssh connection to the Database server. – icy3 Oct 06 '19 at 22:05

1 Answers1

0

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} 
icy3
  • 1