How to use barman to backup PostgreSQL database correctly? I am using PostgreSQL 10 now. Installed newest Barman on RHEL 7.

When I run this command by barman user:

-bash-4.2$ barman receive-wal pg
Starting receive-wal for server pg
ERROR: ArchiverFailure:pg_receivexlog not present in $PATH


Official Introduction

WAL streaming

Barman can reduce the Recovery Point Objective (RPO) by allowing users to add continuous WAL streaming from a PostgreSQL server, on top of the standard archive_command strategy.

Barman relies on pg_receivewal, a utility that has been available from PostgreSQL 9.2 which exploits the native streaming replication protocol and continuously receives transaction logs from a PostgreSQL server (master or standby). Prior to PostgreSQL 10, pg_receivewal was named pg_receivexlog.

IMPORTANT: Barman requires that pg_receivewal is installed on the same server. For PostgreSQL 9.2 servers, you need pg_receivexlog of version 9.2 installed alongside Barman. For PostgreSQL 9.3 and above, it is recommended to install the latest available version of pg_receivewal, as it is back compatible. Otherwise, users can install multiple versions of pg_receivewal/pg_receivexlog on the Barman server and properly point to the specific version for a server, using the path_prefix option in the configuration file.

In order to enable streaming of transaction logs, you need to:

setup a streaming connection as previously described
set the streaming_archiver option to on
The cron command, if the aforementioned requirements are met, transparently manages log streaming through the execution of the receive-wal command. This is the recommended scenario.

However, users can manually execute the receive-wal command:
barman receive-wal &lt;server_name&gt;


It said:

Prior to PostgreSQL 10, pg_receivewal was named pg_receivexlog.


Why it's version 10, got pg_receivexlog error?



Check Backup

When I check backup, got:

-bash-4.2$ barman check pg
Server pg:
    WAL archive: FAILED (please make sure WAL shipping is setup)
    PostgreSQL: OK
    is_superuser: OK
    PostgreSQL streaming: OK
    wal_level: OK
    replication slot: FAILED (slot 'barman' not initialised: is 'receive-wal' running?)
    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: OK (have 0 backups, expected at least 0)
    pg_basebackup: OK
    pg_basebackup compatible: OK
    pg_basebackup supports tablespaces mapping: OK
    systemid coherence: OK (no system Id stored on disk)
    pg_receivexlog: FAILED
    pg_receivexlog compatible: FAILED (PostgreSQL version: 10.12, pg_receivexlog version: None)
    receive-wal running: FAILED (See the Barman log file for more details)
    archiver errors: OK


How to fix the failed items?



Edit

When I check pg_receivewal by postgres user:

$ sudo su - postgres
-bash-4.2$ pg_receivewal
-bash: pg_receivewal: command not found
-bash-4.2$ psql
psql (9.2.24, server 10.12)
WARNING: psql version 9.2, server version 10.0.
         Some psql features might not work.
Type "help" for help.


PostgreSQL version: 10.12, pg_receivewal not exist?
When pg_receivexlog was renamed, barman didn't add sprinkle conditional error messages all over its code.  It is looking for pg_receivewal, but the text of the error message still says "pg_receivexlog" as an umbrella term to cover whichever applies.

The solution is to add the directory holding pg_receivewal to your $PATH.  It should already be there, but apparently it isn't.  How did you install both PostgreSQL and barman?  Which OS user are you running this command as?