2

I am in the process of setting up a database backup system using Barman.

My database is a postgreSQL db.

When I run

barman check main-db

I get the following error:

        PostgreSQL: FAILED
        directories: OK
        retention policy settings: OK
        backup maximum age: FAILED (interval provided: 1 day, latest backup age: No available backups)
        compression settings: OK
        minimum redundancy requirements: OK (have 0 backups, expected at least 0)
        ssh: OK (PostgreSQL server)
        not in recovery: OK

The code I'm using in my barman.conf:

ssh_command = ssh postgres@10.0.0.XX

conninfo = host=10.0.0.XX user=YYYYYYY dbname=ZZZZZZZZ

retention_policy_mode = auto
retention_policy = RECOVERY WINDOW OF 7 days
wal_retention_policy = main

Any help would be greatly appreciated

mnencia
  • 3,298
  • 1
  • 23
  • 35
anthonyjc93
  • 31
  • 2
  • 5

3 Answers3

3

The barman check output contains two errors, the first one is critical:

  • PostgreSQL: FAILED

It means that your barman user cannot connect with PostgreSQL using the credentials you provided in the conninfo parameter.

You can try it yourself by becoming the barman user and executing psql passing the content of conninfo as the only argument (it requires PostgreSQL clients installed on the server):

psql 'host=10.0.0.XX user=YYYYYYY dbname=ZZZZZZZZ'

It must connect to the target PostgreSQL servers without asking for any password.

The backup maximum age error is normal because you don't have any backup. However, it is not a blocking one, so it will not prevent you from taking your first backup.

Ammar
  • 73
  • 6
mnencia
  • 3,298
  • 1
  • 23
  • 35
  • Hi thanks for the reply. When attempting to call psql 'host= ...... " I get the following: "could not connect to server: connection refused Is the server running ........" On the server running my Postgresql DB I called the following: "nmap 10.0.0.27 -p 5432" and recieved the following message: "PORT START SERVICE 5432/tcp closed postgresql" So im guessing my next focus should be looking at opening the above port? – anthonyjc93 Feb 12 '18 at 03:35
  • UPDATE: 'psql 'host=10.0.0.XX user=YYYYYYY dbname=ZZZZZZZZ' Does NOT work, however 'psql -h 10.0.0.XX -p 3385 -U USER DB' does work. – anthonyjc93 Feb 12 '18 at 05:30
  • So your PostgreSQL server runs on a non-standard port. You must specify it in the `conninfo` parameter by adding ` port=3385` – mnencia Feb 12 '18 at 05:57
0

This issue has now been resolved.

I solved this issue by ensuring that conninfo= had all the correct information. (Including password= field)

anthonyjc93
  • 31
  • 2
  • 5
  • To store passwords, it is batter to use the `.pgpass` file in the barman user home. Doing that way the password is totally managed by PostgreSQL client library and never appears in the process listing output. Ref: https://www.postgresql.org/docs/10/static/libpq-pgpass.html – mnencia Feb 12 '18 at 07:36
0

I think you deleted your barman user from PostgreSQL or you recreated that PostgreSQL cluster using postgresql-12-setup initdb command. Either you recover from old backup or you can do follow below steps.

postgres@pg$ createuser -s -P barman

postgres@pg$ psql

GRANT EXECUTE ON FUNCTION pg_start_backup(text, boolean, boolean) to barman;
GRANT EXECUTE ON FUNCTION pg_stop_backup() to barman;
GRANT EXECUTE ON FUNCTION pg_stop_backup(boolean, boolean) to barman;
GRANT EXECUTE ON FUNCTION pg_switch_wal() to barman;
GRANT EXECUTE ON FUNCTION pg_create_restore_point(text) to barman;
GRANT pg_read_all_settings TO barman;
GRANT pg_read_all_stats TO barman;

For streaming backup, you need to create streaming connection.

postgres@pg$ createuser -P --replication streaming_barman

Next update your pg_hba.conf file with your granted ip address.

Peter Csala
  • 17,736
  • 16
  • 35
  • 75