()

Configure Streaming Backup & WAL Streaming using BARMAN in PostgreSQL

In our previous blog, we saw steps to set up Traditional BARMAN Setup via rsync/SSH Click here to read more. 

In this blog, we will see How to Configure Streaming Backup & WAL Streaming using BARMAN in PostgreSQL.

Traditionally, Barman has always operated remotely via SSH, taking advantage of rsync for physical backup operations. Version 2.0 introduces native support for PostgreSQL’s streaming replication protocol for backup operations, via pg_basebackup. Barman has supported standard WAL file shipping through PostgreSQL’s archive_command usually via rsync/SSH, now via barman-wal-archive from the barman-cli package. Barman 1.6.0 introduces streaming of WAL files for PostgreSQL servers 9.2 or higher, as an additional method for transactional log archiving, through pg_receivewal. Barman 2.0 introduces support for replication slots with PostgreSQL servers 9.4 or above, therefore allowing WAL streaming-only configurations.

With Standard archiving WAL files are archived only when PostgreSQL switches to a new WAL file. To keep it simple, this normally happens every 16MB worth of data changes. The advantage of streaming WAL records is that it doesn’t wait for the capacity to be full, these are streamed immediately. WAL streaming is able to reduce the risk of data loss, bringing RPO down to near zero values.

Sr NoHostnameIPRole
1test-machine01192.168.114.177Barman Server (Backup Server)
2test-machine02192.168.114.176PostgreSQL Database Server

Follow the below steps to install and configure barman


Step 1. Verify PostgreSQL repository: Use OS command yum repolist to confirm postgresql repository exist in Backup ServerClick here to configure postgresql repository if it is not configured.

[root@test-machine01 ~]# yum repolist
Loaded plugins: langpacks, ulninfo
repo id                                                              repo name                                                                                                          status
!mysql-connectors-community/x86_64                                   MySQL Connectors Community                                                                                            203
!mysql-tools-community/x86_64                                        MySQL Tools Community                                                                                                 129
!mysql80-community/x86_64                                            MySQL 8.0 Community Server                                                                                            265
!ol7_UEKR5/x86_64                                                    Latest Unbreakable Enterprise Kernel Release 5 for Oracle Linux 7Server (x86_64)                                      404
!ol7_UEKR6/x86_64                                                    Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 7Server (x86_64)                                      323
!ol7_latest/x86_64                                                   Oracle Linux 7Server Latest (x86_64)                                                                               22,766
!pgdg-common/7Server/x86_64                                          PostgreSQL common RPMs for RHEL/CentOS 7Server - x86_64                                                               303
!pgdg10/7Server/x86_64                                               PostgreSQL 10 for RHEL/CentOS 7Server - x86_64                                                                        918
!pgdg11/7Server/x86_64                                               PostgreSQL 11 for RHEL/CentOS 7Server - x86_64                                                                      1,006
!pgdg12/7Server/x86_64                                               PostgreSQL 12 for RHEL/CentOS 7Server - x86_64                                                                        572
!pgdg13/7Server/x86_64                                               PostgreSQL 13 for RHEL/CentOS 7Server - x86_64                                                                        298
!pgdg95/7Server/x86_64                                               PostgreSQL 9.5 for RHEL/CentOS 7Server - x86_64                                                                       763
!pgdg96/7Server/x86_64                                               PostgreSQL 9.6 for RHEL/CentOS 7Server - x86_64                                                                       889
repolist: 28,839
[root@test-machine01 ~]#


Step 2. Install barman: Use OS command yum install barman to install barman package in Backup Server.

[root@test-machine01 tmp]# yum install barman
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package barman.noarch 0:2.12-1.rhel7 will be installed
--> Processing Dependency: python-barman = 2.12 for package: barman-2.12-1.rhel7.noarch
--> Running transaction check
---> Package python-barman.noarch 0:2.12-1.rhel7 will be installed
--> Processing Dependency: python-psycopg2 >= 2.4.2 for package: python-barman-2.12-1.rhel7.noarch
--> Running transaction check
---> Package python2-psycopg2.x86_64 0:2.8.6-1.rhel7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
==============================================================================================================================================================================================
 Package                                           Arch                                    Version                                         Repository                                    Size
==============================================================================================================================================================================================
Installing:
 barman                                            noarch                                  2.12-1.rhel7                                    pgdg-common                                   36 k
Installing for dependencies:
 python-barman                                     noarch                                  2.12-1.rhel7                                    pgdg-common                                  356 k
 python2-psycopg2                                  x86_64                                  2.8.6-1.rhel7                                   pgdg-common                                  171 k
 
Transaction Summary
==============================================================================================================================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 563 k
Installed size: 2.5 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): barman-2.12-1.rhel7.noarch.rpm                                                                                                                                  |  36 kB  00:00:01
(2/3): python2-psycopg2-2.8.6-1.rhel7.x86_64.rpm                                                                                                                       | 171 kB  00:00:01
(3/3): python-barman-2.12-1.rhel7.noarch.rpm                                                                                                                           | 356 kB  00:00:03
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         176 kB/s | 563 kB  00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : python2-psycopg2-2.8.6-1.rhel7.x86_64                                                                                                                                      1/3
  Installing : python-barman-2.12-1.rhel7.noarch                                                                                                                                          2/3
  Installing : barman-2.12-1.rhel7.noarch                                                                                                                                                 3/3
  Verifying  : python2-psycopg2-2.8.6-1.rhel7.x86_64                                                                                                                                      1/3
  Verifying  : barman-2.12-1.rhel7.noarch                                                                                                                                                 2/3
  Verifying  : python-barman-2.12-1.rhel7.noarch                                                                                                                                          3/3
 
Installed:
  barman.noarch 0:2.12-1.rhel7
 
Dependency Installed:
  python-barman.noarch 0:2.12-1.rhel7                                                         python2-psycopg2.x86_64 0:2.8.6-1.rhel7
 
Complete!
[root@test-machine01 tmp]#


Step 3. In case of Error: In case if you encounter errors Error: Package: python-barman-2.12-1.rhel7.noarch (pgdg-common) Requires: python-argcomplete & Error: Package: python-barman-2.12-1.rhel7.noarch (pgdg-common) Requires: python-argh >= 0.21.2 in yum install barman command. Download rpm python2-argh-0.26.1-5.el7.noarch.rpm & python2-argcomplete-1.7.0-4.el7.noarch.rpm from below links and transfer these rpm to Backup Server and install the rpm and then try to install barman package.

https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/p/python2-argcomplete-1.7.0-4.el7.noarch.rpm
https://download-ib01.fedoraproject.org/pub/epel/7/aarch64/Packages/p/python2-argh-0.26.1-5.el7.noarch.rpm

[root@test-machine01 u01]# yum install barman
Loaded plugins: langpacks, ulninfo
Repository ol7_UEKR5 is listed more than once in the configuration
Repository ol7_UEKR4 is listed more than once in the configuration
Repository ol7_UEKR3 is listed more than once in the configuration
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-barman.noarch 0:2.12-1.rhel7 will be installed
--> Processing Dependency: python-argh >= 0.21.2 for package: python-barman-2.12-1.rhel7.noarch
--> Processing Dependency: python-argcomplete for package: python-barman-2.12-1.rhel7.noarch
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Finished Dependency Resolution
Error: Package: python-barman-2.12-1.rhel7.noarch (pgdg-common)
           Requires: python-argcomplete
Error: Package: python-barman-2.12-1.rhel7.noarch (pgdg-common)
           Requires: python-argh >= 0.21.2
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
[root@test-machine01 u01]#
 
root@test-machine01 u01]# cd /tmp
[root@test-machine01 tmp]#
[root@test-machine01 tmp]# ls -ltr
total 156
-rw-r--r--. 1 root root 55120 Jun 22 09:57 python2-argh-0.26.1-5.el7.noarch.rpm
-rw-r--r--. 1 root root 50402 Jun 22  2021 python2-argcomplete-1.7.0-4.el7.noarch.rpm
[root@test-machine01 u01]#
 
[root@test-machine01 tmp]# rpm -ivh python2-argh-0.26.1-5.el7.noarch.rpm
warning: python2-argh-0.26.1-5.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:python2-argh-0.26.1-5.el7        ################################# [100%]
[root@test-machine01 tmp]#
 
[root@test-machine01 tmp]# rpm -ivh python2-argcomplete-1.7.0-4.el7.noarch.rpm
warning: python2-argcomplete-1.7.0-4.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:python2-argcomplete-1.7.0-4.el7  ################################# [100%]
[root@test-machine01 tmp]#
 
 
 
[root@test-machine01 tmp]# yum install barman
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package barman.noarch 0:2.12-1.rhel7 will be installed
--> Processing Dependency: python-barman = 2.12 for package: barman-2.12-1.rhel7.noarch
--> Running transaction check
---> Package python-barman.noarch 0:2.12-1.rhel7 will be installed
--> Processing Dependency: python-psycopg2 >= 2.4.2 for package: python-barman-2.12-1.rhel7.noarch
--> Running transaction check
---> Package python2-psycopg2.x86_64 0:2.8.6-1.rhel7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
==============================================================================================================================================================================================
 Package                                           Arch                                    Version                                         Repository                                    Size
==============================================================================================================================================================================================
Installing:
 barman                                            noarch                                  2.12-1.rhel7                                    pgdg-common                                   36 k
Installing for dependencies:
 python-barman                                     noarch                                  2.12-1.rhel7                                    pgdg-common                                  356 k
 python2-psycopg2                                  x86_64                                  2.8.6-1.rhel7                                   pgdg-common                                  171 k
 
Transaction Summary
==============================================================================================================================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 563 k
Installed size: 2.5 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): barman-2.12-1.rhel7.noarch.rpm                                                                                                                                  |  36 kB  00:00:01
(2/3): python2-psycopg2-2.8.6-1.rhel7.x86_64.rpm                                                                                                                       | 171 kB  00:00:01
(3/3): python-barman-2.12-1.rhel7.noarch.rpm                                                                                                                           | 356 kB  00:00:03
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         176 kB/s | 563 kB  00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : python2-psycopg2-2.8.6-1.rhel7.x86_64                                                                                                                                      1/3
  Installing : python-barman-2.12-1.rhel7.noarch                                                                                                                                          2/3
  Installing : barman-2.12-1.rhel7.noarch                                                                                                                                                 3/3
  Verifying  : python2-psycopg2-2.8.6-1.rhel7.x86_64                                                                                                                                      1/3
  Verifying  : barman-2.12-1.rhel7.noarch                                                                                                                                                 2/3
  Verifying  : python-barman-2.12-1.rhel7.noarch                                                                                                                                          3/3
 
Installed:
  barman.noarch 0:2.12-1.rhel7
 
Dependency Installed:
  python-barman.noarch 0:2.12-1.rhel7                                                         python2-psycopg2.x86_64 0:2.8.6-1.rhel7
 
Complete!
[root@test-machine01 tmp]#


Step 4. Verify barman package installation: yum install barman will create barman account in Server. Use command barman –version to verify install barman version in Backup Server.

[root@test-machine01 tmp]# id barman
uid=994(barman) gid=990(barman) groups=990(barman)
[root@test-machine01 tmp]#
[root@test-machine01 tmp]# su - barman
-bash-4.2$
-bash-4.2$ whoami
barman
-bash-4.2$
 
-bash-4.2$ barman --version
2.12
 
Barman by 2ndQuadrant (www.2ndQuadrant.com)
-bash-4.2$


Step 5. Create barman role: Create role barman in PostgreSQL Database Server. This role will use for a standard connection to PostgreSQL, for management, coordination, and monitoring purposes.

[root@test-machine02 ~]# su - postgres
Last login: Tue Jun 22 15:06:21 +03 2021 on pts/0
-bash-4.2$ psql
psql (13.2)
Type "help" for help.
postgres=#
postgres=# create user barman superuser  password 'barman';
CREATE ROLE
postgres=#


Step 6. Create streaming_barman role: Create role streaming_barman in PostgreSQL Database Server. This role will use for a streaming replication connection that will be used by both pg_basebackup (for base backup operations) and pg_receivewal (for WAL streaming) and verify that the streaming connection works through the command “psql -U streaming_barman -h test-machine02 -c “IDENTIFY_SYSTEM” replication=1″. Also make sure PostgreSQL configuration parameters like wal_level, max_replication_slots, max_wal_senders set to the below value.

[root@test-machine02 ~]# su - postgres
Last login: Sun Jul 11 10:51:34 +03 2021 on pts/1
-bash-4.2$
-bash-4.2$ psql
psql (13.2)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".
postgres=#
postgres=# create user streaming_barman with replication password 'barman';
CREATE ROLE
postgres=#
postgres=# \du+
                                                 List of roles
    Role name     |                         Attributes                         |    Member of     | Description
------------------+------------------------------------------------------------+------------------+-------------
 barman           | Superuser                                                  | {}               |
 postgres         | Superuser, Create role, Create DB, Replication, Bypass RLS | {}               |
 streaming_barman | Replication                                                | {}               |

postgres=#
postgres=# select name,setting,unit from pg_settings where name in ('wal_level','max_wal_senders','max_replication_slots');
         name          | setting | unit
-----------------------+---------+------
 max_replication_slots | 10      |
 max_wal_senders       | 10      |
 wal_level             | replica |
(3 rows)

-bash-4.2$ psql -U streaming_barman -h test-machine02 -c "IDENTIFY_SYSTEM"   replication=1
Password for user streaming_barman:
      systemid       | timeline |  xlogpos   | dbname
---------------------+----------+------------+--------
 6955437016975533153 |        2 | 0/440010B0 |
(1 row)

-bash-4.2$


Step 7. Configure Global Configuration File in Barman Server: The main configuration file (set to /etc/barman.conf by default) contains general options such as main directory, system user, log file, and so on. Edit /etc/barman.conf to set global parameters. Set the below parameters and save the file.

[root@test-machine01 etc]# pwd
/etc
[root@test-machine01 etc]# vi barman.conf
[barman]
barman_user = barman
configuration_files_directory = /etc/barman.d
barman_home = /var/lib/barman
log_file = /var/log/barman/barman.log
log_level = INFO
compression = gzip
immediate_checkpoint = true
basebackup_retry_times = 3
minimum_redundancy = 3
retention_policy = RECOVERY WINDOW OF 7 DAYS
:wq!


Step 8. Configure Server configuration files in Barman Server: Server configuration files, one for each server to be backed up by Barman, is located in the /etc/barman.d directory and must have a .conf suffix. Please note user=barman & user=streaming_barman is the same role we created in Step 5 & 6. Set the below parameters and save the file.

oot@test-machine01 ~]# 
[root@test-machine01 ~]# cd /etc/barman.d
[root@test-machine01 barman.d]#
[root@test-machine01 barman.d]# ls -ltr
total 12
-rw-r--r--. 1 root root 1492 Nov  4  2020 streaming-server.conf-template
-rw-r--r--. 1 root root 1565 Nov  4  2020 ssh-server.conf-template
-rw-r--r--. 1 root root  947 Nov  4  2020 passive-server.conf-template
[root@test-machine01 barman.d]# vi streaming-backup.conf
[streaming-backup]
description =  "Example of PostgreSQL Database (Streaming-Only)"
conninfo = host=test-machine02 user=barman port=5432
streaming_conninfo = host=test-machine02 user=streaming_barman port=5432
backup_method = postgres
streaming_archiver = on
slot_name = barman
create_slot = auto
:wq!
[root@test-machine01 barman.d]# ls -ltr
total 16
-rw-r--r--. 1 root root 1492 Nov  4  2020 streaming-server.conf-template
-rw-r--r--. 1 root root 1565 Nov  4  2020 ssh-server.conf-template
-rw-r--r--. 1 root root  947 Nov  4  2020 passive-server.conf-template
-rw-r--r--. 1 root root  226 Jun 22 11:50 streaming-backup.conf
[root@test-machine01 barman.d]# 


Step 9. Create pgpass file: We are using pgpass file to avoid adding password in configuration files.
Format : hostname : port : database : username : password, Please note for user : streaming_barman we have to add keyword replication instead of database name.

-bash-4.2$ pwd
/var/lib/barman
-bash-4.2$ vi .pgpass
test-machine02:5432:postgres:barman:barman
test-machine02:5432:replication:streaming_barman:barman
:wq!
-bash-4.2$ chmod 0600 .pgpass
-bash-4.2$
-bash-4.2$ export PGPASSFILE=/var/lib/barman/.pgpass
-bash-4.2$
-bash-4.2$ echo $PGPASSFILE
/var/lib/barman/.pgpass

-bash-4.2$ ls -l /var/lib/barman/.pgpass
-rw-------. 1 barman barman 99 Jul 11 13:19 /var/lib/barman/.pgpass
-bash-4.2$


Step 10. Start  Log Streaming: Before starting log stream make sure PATH for utility pg_receivewal is set otherwise you will receive error “ERROR: ArchiverFailure:pg_receivexlog not present in $PATH“. Use command barman receive-wal to start Log Streaming. Use command barman check to check everything is fine.

-bash-4.2$
-bash-4.2$ export PATH=$PATH:/usr/pgsql-13/bin/
You have new mail in /var/spool/mail/barman
-bash-4.2$
-bash-4.2$ whereis pg_receivewal
pg_receivewal: /usr/pgsql-13/bin/pg_receivewal
-bash-4.2$

-bash-4.2$
-bash-4.2$ barman receive-wal streaming-backup &
[1] 22508
-bash-4.2$ Starting receive-wal for server streaming-backup
streaming-backup: pg_receivewal: starting log streaming at 0/45000000 (timeline 2)
-bash-4.2$

-bash-4.2$ barman check streaming-backup
Server streaming-backup:
        PostgreSQL: OK
        superuser or standard user with backup privileges: OK
        PostgreSQL streaming: OK
        wal_level: OK
        replication slot: 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 3)
        pg_basebackup: OK
        pg_basebackup compatible: OK
        pg_basebackup supports tablespaces mapping: OK
        systemid coherence: OK (no system Id stored on disk)
        pg_receivexlog: OK
        pg_receivexlog compatible: OK
        receive-wal running: OK
        archiver errors: OK
You have new mail in /var/spool/mail/barman

-bash-4.2$
-bash-4.2$ ps -ef|grep barman
root      15182 124521  0 11:52 pts/0    00:00:00 su - barman
barman    15183  15182  0 11:52 pts/0    00:00:00 -bash
barman    22508  15183  0 13:38 pts/0    00:00:00 /usr/bin/python2 /bin/barman receive-wal streaming-backup
barman    22510  22508  0 13:38 pts/0    00:00:00 /usr/pgsql-13/bin/pg_receivewal --dbname=dbname=replication host=test-machine02 options=-cdatestyle=iso port=5432 replication=true user=streaming_barman application_name=barman_receive_wal --verbose --no-loop --no-password --directory=/var/lib/barman/streaming-backup/streaming --slot=barman
barman    22577  15183  0 13:39 pts/0    00:00:00 ps -ef
barman    22578  15183  0 13:39 pts/0    00:00:00 grep --color=auto barman
-bash-4.2$


Step 11. Check barman Streaming Configuration: There are many commands to check if the configuration is working fine. We have listed below, barman replication-status, barman status. You can also login to PostgreSQL Database and check the process with a select query. Use command barman show-server to view full configuration settings.

-bash-4.2$ barman replication-status streaming-backup
Status of streaming clients for server 'streaming-backup':
  Current LSN on master: 0/450001C0
  Number of streaming clients: 1

  1. Async WAL streamer
     Application name: barman_receive_wal
     Sync stage      : 3/3 Remote write
     Communication   : TCP/IP
     IP Address      : 192.168.114.177 / Port: 29788 / Host: -
     User name       : streaming_barman
     Current state   : streaming (async)
     Replication slot: barman
     WAL sender PID  : 72702
     Started at      : 2021-07-11 13:38:44.746873+03:00
     Sent LSN   : 0/450001C0 (diff: 0 B)
     Write LSN  : 0/450001C0 (diff: 0 B)
     Flush LSN  : 0/45000000 (diff: -448 B)
-bash-4.2$

-bash-4.2$ barman status streaming-backup
Server streaming-backup:
        Description: Example of PostgreSQL Database (Streaming-Only)
        Active: True
        Disabled: False
        PostgreSQL version: 13.2
        Cluster state: in production
        pgespresso extension: Not available
        Current data size: 47.4 MiB
        PostgreSQL Data directory: /var/lib/pgsql/13/data
        Current WAL segment: 000000020000000000000045
        Passive node: False
        Retention policies: enforced (mode: auto, retention: RECOVERY WINDOW OF 7 DAYS, WAL retention: MAIN)
        No. of available backups: 0
        First available backup: None
        Last available backup: None
        Minimum redundancy requirements: FAILED (0/3)
-bash-4.2$

-bash-4.2$  barman show-server  streaming-backup
Server streaming-backup:
        active: True
        archive_timeout: 21600
        archiver: False
        archiver_batch_size: 0
        backup_directory: /var/lib/barman/streaming-backup
        backup_method: postgres
        backup_options: BackupOptions(['concurrent_backup'])
        bandwidth_limit: None
        barman_home: /var/lib/barman
        barman_lock_directory: /var/lib/barman
        basebackup_retry_sleep: 30
        basebackup_retry_times: 3
        basebackups_directory: /var/lib/barman/streaming-backup/base
        check_timeout: 30
        checkpoint_timeout: 300

postgres=# select * from pg_replication_slots;
 slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn | wal_status | safe_wal_size
-----------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------+------------+---------------
 barman    |        | physical  |        |          | f         | t      |      72702 |      |              | 0/45000000  |                     | reserved   |
(1 row)


Step 12. Verify WAL streaming and Streaming backup: Perform manual switch of WAL using command barman switch-wal and verify same current WAL is existing in WAL Streaming folder. Perform Streaming backup using barman backup command.

-bash-4.2$
-bash-4.2$ barman switch-wal --force --archive streaming-backup
The WAL file 000000020000000000000045 has been closed on server 'streaming-backup'
Waiting for the WAL file 000000020000000000000045 from server 'streaming-backup' (max: 30 seconds)
streaming-backup: pg_receivewal: finished segment at 0/46000000 (timeline 2)
Processing xlog segments from streaming for streaming-backup
        000000020000000000000045
-bash-4.2$
-bash-4.2$ pwd
/var/lib/barman/streaming-backup/streaming
-bash-4.2$ ls -ltr
total 16384
-rw-------. 1 barman barman 16777216 Jul 11 14:06 000000020000000000000046.partial
-bash-4.2$

-bash-4.2$ barman backup streaming-backup
Starting backup using postgres method for server streaming-backup in /var/lib/barman/streaming-backup/base/20210711T144809
Backup start at LSN: 0/48000000 (000000020000000000000047, 00000000)
Starting backup copy via pg_basebackup for 20210711T144809
streaming-backup: pg_receivewal: finished segment at 0/49000000 (timeline 2)
streaming-backup: pg_receivewal: finished segment at 0/4A000000 (timeline 2)
Copy done (time: 1 second)
Finalising the backup.
This is the first backup for server streaming-backup
WAL segments preceding the current backup have been found:
        000000020000000000000045 from server streaming-backup has been removed
        000000020000000000000046 from server streaming-backup has been removed
Backup size: 51.6 MiB
Backup end at LSN: 0/4A000000 (000000020000000000000049, 00000000)
Backup completed (start time: 2021-07-11 14:48:09.605688, elapsed time: 1 second)
Processing xlog segments from streaming for streaming-backup
        000000020000000000000047
        000000020000000000000048
WARNING: IMPORTANT: this backup is classified as WAITING_FOR_WALS, meaning that Barman has not received yet all the required WAL files for the backup consistency.
This is a common behaviour in concurrent backup scenarios, and Barman automatically set the backup as DONE once all the required WAL files have been archived.
Hint: execute the backup command with '--wait'
-bash-4.2$
-bash-4.2$ barman list-backup streaming-backup
streaming-backup 20210711T144809 - Sun Jul 11 14:48:07 2021 - Size: 51.6 MiB - WAL Size: 0 B (tablespaces: myts01:/u01/psql_tbls, myts02:/u01/psql2_tbls) - WAITING_FOR_WALS
You have new mail in /var/spool/mail/barman
-bash-4.2$

-bash-4.2$
-bash-4.2$  barman list-backup streaming-backup
streaming-backup 20210711T144809 - Sun Jul 11 14:48:07 2021 - Size: 51.6 MiB - WAL Size: 0 B (tablespaces: myts01:/u01/psql_tbls, myts02:/u01/psql2_tbls)
-bash-4.2$


Step 13. Configure cron: Since barman doesn’t include a long-running daemon or service file there’s nothing command like systemctl start barman cron or service start barman cron etc. So it is recommended to schedule barman cron to run every minute. The barman cron command ensures that WAL streaming is started for those servers that have requested it, by transparently executing the receive-wal command.

-bash-4.2$ crontab -l
* * * * * export PATH=$PATH:/usr/pgsql-13/bin; barman cron >/dev/null 2>&1
-bash-4.2$


References: BARMAN Document: http://docs.pgbarman.org/release/2.12/
For BARMAN Backup Command: https://dbsguru.com/physical-postgresql-backup-using-barman/
For BARMAN Restore Command: https://dbsguru.com/restore-backup-using-barman-in-postgresql/
For BARMAN PITR Comamnd: https://dbsguru.com/point-in-time-recovery-using-barman-in-postgresql/


This document is just for learning purpose and always validate in the LAB environment first before applying in the LIVE environment.


Hope so you like this article
!
Please share your valuable feedback/comments/subscribe and follow us below and don’t forget to click on the bell icon to get the most recent update. Click here to understand more about our pursuit.

 

Related articles


Loading

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Jamsher Khan

Hello and welcome to DBsGuru,I’m Jamsher Khan working as Senior Oracle DBA based in KSA-Jeddah, I have working experience in Oracle DBA, SQL Server, MySql, PostgreSQL, Linux, Golden Gate, ODA.Thanks for the visits!Share Learn Grow!

2 thoughts on “Configure Streaming Backup and WAL Streaming using BARMAN in PostgreSQL

Comments are closed.