Postgresql – Unable to receive WAL files with barman

backupbarmanpg-basebackuppostgresqlwrite-ahead-logging

I've been scratching my head to solve the following error, but haven't made much progress:

$ barman switch-wal --force --archive --archive-timeout 180 pg

The WAL file 0000000100000059000000FF has been closed on server 'pg'
Waiting for the WAL file 0000000100000059000000FF from server 'pg' (max: 180 seconds)
ERROR: The WAL file 0000000100000059000000FF has not been received in 180 seconds

I had earlier configured barman on a throwaway VPS and everything worked fine. But when I tried replicating this on our final EC2 instance, I ran into the issue mentioned above. I have ensured the following (even though I don't remember doing this on the VPS):

  • SSH from barman => pg is working
  • SSH from pg => barman is working
  • All firewall rules on 'pg' have been disabled, temporarily

What could be the issue here?

Edit: Adding the output of barman check pg

Server pg:
2017-12-08 05:56:31,841 [14559] barman.server ERROR: Check 'WAL archive' failed for server 'pg'
    WAL archive: FAILED (please make sure WAL shipping is setup)
    PostgreSQL: OK
    is_superuser: OK
    PostgreSQL streaming: OK
    wal_level: OK
2017-12-08 05:56:34,174 [14559] barman.server ERROR: Check 'replication slot' failed for server 'pg'
    replication slot: FAILED (slot 'pgbackup' not active: is 'receive-wal' running?)
    directories: OK
    retention policy settings: OK
2017-12-08 05:56:34,175 [14559] barman.server ERROR: Check 'backup maximum age' failed for server 'pg'
    backup maximum age: FAILED (interval provided: 14 days, latest backup age: No available backups)
    compression settings: OK
    failed backups: OK (there are 0 failed backups)
2017-12-08 05:56:34,175 [14559] barman.server ERROR: Check 'minimum redundancy requirements' failed for server 'pg'
    minimum redundancy requirements: FAILED (have 0 backups, expected at least 3)
    pg_basebackup: OK
    pg_basebackup compatible: OK
    pg_basebackup supports tablespaces mapping: OK
    pg_receivexlog: OK
    pg_receivexlog compatible: OK
2017-12-08 05:56:34,367 [14559] barman.server ERROR: Check 'receive-wal running' failed for server 'pg'
    receive-wal running: FAILED (See the Barman log file for more details)
    archiver errors: OK

Edit: Added output of barman receive-wal pg

$ sudo barman receive-wal pg
2017-12-10 01:48:01,129 [25410] barman.utils WARNING: Failed opening the requested log file. Using standard error instead.
Starting receive-wal for server pg
2017-12-10 01:48:01,138 [25410] barman.server INFO: Starting receive-wal for server pg
2017-12-10 01:48:03,087 [25410] barman.wal_archiver INFO: Activating WAL archiving through streaming protocol
pg: pg_receivexlog: starting log streaming at 5A/A000000 (timeline 1)
2017-12-10 01:48:03,391 [25410] barman.command_wrappers INFO: pg: pg_receivexlog: starting log streaming at 5A/A000000 (timeline 1)

^CSIGINT received. Terminate gracefully.
2017-12-10 01:50:42,512 [25410] barman.wal_archiver INFO: SIGINT received. Terminate gracefully.

Edit: Configuration files —

; --------------------
; Contents of /etc/barman.conf after removing all commented lines.
; --------------------

[barman]
barman_user = ubuntu
path_prefix = /home/ubuntu/pg/bin
configuration_files_directory = /home/ubuntu/barman.conf.d
barman_home = /home/ubuntu/barman
log_file = /var/log/barman/barman.log
log_level = INFO
compression = bzip2
retention_policy = RECOVERY WINDOW OF 1 MONTH
last_backup_maximum_age = 2 WEEKS
minimum_redundancy = 3
retention_policy = RECOVERY WINDOW OF 4 WEEKS

/home/ubuntu/barman.conf.d/pg.conf:

; --------------------
; Contents of /home/ubuntu/barman.conf.d/pg.conf after removing all commented lines.
; --------------------

[pg]
description =  "Postgres DB"
conninfo = host=REDACTED user=REDACTED dbname=REDACTED
backup_method = postgres
archiver = off
streaming_conninfo =  host=REDACTED user=REDACTED dbname=REDACTED
streaming_archiver = on
slot_name = pgbackup

Best Answer

When you run into a problem like this one, be sure to double-check your logs, the barman check command, and make sure you set a barman cron entry to start barman receive-wal. That needs to be running before you can execute barman switch-wal and finish your setup. =)