1

I'm trying to setup streaming replication to a Barman server.

Barman config is pretty much basic, I'm using backup_method = postgres.

[barman]
barman_home = /var/lib/barman
barman_user = barman
log_file = /var/log/barman/barman.log
log_level = DEBUG
archiver = true
backup_method = postgres
backup_options = concurrent_backup
compression = gzip
minimum_redundancy = 1
retention_policy = RECOVERY WINDOW OF 7 DAYS
retention_policy_mode = auto
streaming_archiver = true
wal_retention_policy = main
configuration_files_directory = /etc/barman.conf.d

I'll call the DB server pg

[pg]
description = "pg"
ssh_command = ssh postgres@pg.example.com
conninfo = user=barman dbname=postgres host=pg.example.com port=5432

I've configure hba rules and setup a .pgpass file in barman's home /var/lib/barman/.pgpass.

A test connection to pg server works just fine:

barman@b01:~$ psql -c 'SELECT version()' -U barman -h pg.example.com postgres
                                                             version                                                              
----------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 10.7 (Debian 10.7-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
(1 row)

However barman check pg fails miserably and I have no idea why:

$ barman check pg
Server pg:
        WAL archive: FAILED (please make sure WAL shipping is setup)
        PostgreSQL: OK
        is_superuser: OK
        PostgreSQL streaming: FAILED (fe_sendauth: no password supplied)
        wal_level: OK
        directories: OK
        retention policy settings: OK
        backup maximum age: OK (no last_backup_maximum_age provided)
        compression settings: OK
        failed backups: OK (there are 0 failed backups)
        minimum redundancy requirements: FAILED (have 0 backups, expected at least 1)
        pg_basebackup: OK
        pg_basebackup compatible: FAILED (PostgreSQL version: None, pg_basebackup version: 11.2-1.pgdg90+1))
        pg_basebackup supports tablespaces mapping: OK
        archive_mode: OK
        archive_command: FAILED (please set it accordingly to documentation)
        pg_receivexlog: OK
        pg_receivexlog compatible: FAILED (PostgreSQL version: None, pg_receivexlog version: 11.2-1.pgdg90+1))
        receive-wal running: FAILED (See the Barman log file for more details)
        archiver errors: OK

Is there a better way how to debug authentication issues? Is the .pgpass even loaded under barman check?

pg.example.com:5432:postgres:barman:s3cr3tP2ssw0rd
3

After checking barman's source code, I've realized that barman is actually overwriting the conninfo string:

    # Override 'dbname' parameter. This operation is required to mimic
    # the behaviour of pg_receivexlog and pg_basebackup
    self.conn_parameters['dbname'] = 'replication' 

Which isn't very intuitive, thus the dbname in .pgpass should include replication db:

pg.example.com:5432:replication:barman:s3cr3tP2ssw0rd
| improve this answer | |
  • Barman doesn't have a choice. If you want to do physical replication, you need to connect to the "replication" pseudo-database. – jjanes Feb 26 '19 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.