Showing posts with label barman. Show all posts
Showing posts with label barman. Show all posts

Wednesday, December 28, 2022

PostgreSQL - Barman backup to a location different from the default one /var/lib/barman

Backup PostgreSQL database using BARMAN to a location different from the default location

Objective: 

Update the postgresql backup location in barman server;

We are looking to migrate the backups from default barman user's home directory to a dedicated filesystem where the backups will be hosted.

For instance /var/lib/barman to /var/lib/barman/pgbackups

/var/lib/barman is a dedicated mountpoint for barman users home.

/var/lib/barman/pgbackups which is mounted on top of this directory acts as dedicated backup destination.

You are welcome to choose a seperate mountpath as well.

Steps:

Before the change server config:

-bash-4.2$ barman show-servers primarypostgresql15
Server primarypostgresql15:
        active: True
        archive_timeout: 0
        archiver: False
        archiver_batch_size: 0
        backup_compression: None
        backup_compression_format: None
        backup_compression_level: None
        backup_compression_location: None
        backup_compression_workers: None
        backup_directory: /var/lib/barman/primarypostgresql15
        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: 0
        basebackups_directory: /var/lib/barman/primarypostgresql15/base
        check_timeout: 30
        checkpoint_timeout: 300
        compression: pigz
        config_file: /pgDATA/data/postgresql.conf
        connection_error: None
        conninfo: host=10.0.2.8 user=barman password=*REDACTED* dbname=postgres port=5432
        create_slot: auto
        current_lsn: 0/9A0000D8
        current_size: 1259817117
        current_xlog: 00000001000000000000009A
        custom_compression_filter: None
        custom_compression_magic: None
        custom_decompression_filter: None
        data_checksums: off
        data_directory: /pgDATA/data
        description: Primary PostgreSQL Server Backup
        disabled: False
        errors_directory: /var/lib/barman/primarypostgresql15/errors
        forward_config_path: False
        has_backup_privileges: True
        hba_file: /pgDATA/data/pg_hba.conf
        hot_standby: on
        ident_file: /pgDATA/data/pg_ident.conf
        immediate_checkpoint: False
        incoming_wals_directory: /var/lib/barman/primarypostgresql15/incoming
        is_in_recovery: False
        is_superuser: True
        last_backup_maximum_age: None
        last_backup_minimum_size: None
        last_wal_maximum_age: None
        max_incoming_wals_queue: None
        max_replication_slots: 10
        max_wal_senders: 10
        minimum_redundancy: 0
        msg_list: []
        name: primarypostgresql15
        network_compression: False
        parallel_jobs: 4
        passive_node: False
        path_prefix: "/usr/pgsql-15/bin" # this is needed for streaming archiving, pg_walrecieve command is supplied by postgresql server binary, hence we are installing the postgresql server binary in the barman server
        pg_basebackup_bwlimit: True
        pg_basebackup_compatible: True
        pg_basebackup_installed: True
        pg_basebackup_path: /bin/pg_basebackup
        pg_basebackup_tbls_mapping: True
        pg_basebackup_version: 15.1
        pg_receivexlog_compatible: True
        pg_receivexlog_installed: True
        pg_receivexlog_path: /usr/pgsql-15/bin/pg_receivewal
        pg_receivexlog_supports_slots: True
        pg_receivexlog_synchronous: False
        pg_receivexlog_version: 15.1
        pgespresso_installed: False
        post_archive_retry_script: None
        post_archive_script: None
        post_backup_retry_script: None
        post_backup_script: None
        post_delete_retry_script: None
        post_delete_script: None
        post_recovery_retry_script: None
        post_recovery_script: None
        post_wal_delete_retry_script: None
        post_wal_delete_script: None
        postgres_systemid: 7163531269528114626
        pre_archive_retry_script: None
        pre_archive_script: None
        pre_backup_retry_script: None
        pre_backup_script: None
        pre_delete_retry_script: None
        pre_delete_script: None
        pre_recovery_retry_script: None
        pre_recovery_script: None
        pre_wal_delete_retry_script: None
        pre_wal_delete_script: None
        primary_conninfo: None
        primary_ssh_command: None
        recovery_options: RecoveryOptions([])
        recovery_staging_path: None
        replication_slot: Record(slot_name='barman', active=False, restart_lsn='0/94000000')
        replication_slot_support: True
        retention_policy: RECOVERY WINDOW OF 4 WEEKS
        retention_policy_mode: auto
        reuse_backup: None
        server_txt_version: 15.0
        slot_name: barman
        ssh_command: None
        streaming: True
        streaming_archiver: True
        streaming_archiver_batch_size: 0
        streaming_archiver_name: barman_receive_wal
        streaming_backup_name: barman_streaming_backup
        streaming_conninfo: host=10.0.2.8 user=streaming_barman password=*REDACTED* port=5432
        streaming_supported: True
        streaming_systemid: 7163531269528114626
        streaming_wals_directory: /var/lib/barman/primarypostgresql15/streaming
        synchronous_standby_names: ['']
        tablespace_bandwidth_limit: None
        timeline: 1
        wal_compression: off
        wal_keep_size: 1GB
        wal_level: replica
        wal_retention_policy: MAIN
        wals_directory: /var/lib/barman/primarypostgresql15/wals
        xlog_segment_size: 16777216
        xlogpos: 0/9A0000D8
You have new mail in /var/spool/mail/barman
-bash-4.2


List of directories relying on: /var/lib/barman [which is where our backups are hosted]


Line 16:         backup_directory: /var/lib/barman/primarypostgresql15

Line 20:         barman_home: /var/lib/barman

Line 21:         barman_lock_directory: /var/lib/barman

Line 24:         basebackups_directory: /var/lib/barman/primarypostgresql15/base

Line 42:         errors_directory: /var/lib/barman/primarypostgresql15/errors

Line 49:         incoming_wals_directory: /var/lib/barman/primarypostgresql15/incoming

Line 119:         streaming_wals_directory: /var/lib/barman/primarypostgresql15/streaming

Line 127:         wals_directory: /var/lib/barman/primarypostgresql15/wals


Change server config in the conf file:

[root@localhost barman.d]# diff primarypostgresql15.conf primarypostgresql15.conf_BKP
11,12d10
< ;to alter backup location
< backup_directory = /var/lib/barman/pgbackups/primarypostgresql15
[root@localhost barman.d]#


After the change of server config:

-bash-4.2$ barman show-servers primarypostgresql15
Server primarypostgresql15:
        active: True
        archive_timeout: 0
        archiver: False
        archiver_batch_size: 0
        backup_compression: None
        backup_compression_format: None
        backup_compression_level: None
        backup_compression_location: None
        backup_compression_workers: None
        backup_directory: /var/lib/barman/pgbackups/primarypostgresql15
        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: 0
        basebackups_directory: /var/lib/barman/pgbackups/primarypostgresql15/base
        check_timeout: 30
        checkpoint_timeout: 300
        compression: pigz
        config_file: /pgDATA/data/postgresql.conf
        connection_error: None
        conninfo: host=10.0.2.8 user=barman password=*REDACTED* dbname=postgres port=5432
        create_slot: auto
        current_lsn: 0/9A0001C0
        current_size: 1259817117
        current_xlog: 00000001000000000000009A
        custom_compression_filter: None
        custom_compression_magic: None
        custom_decompression_filter: None
        data_checksums: off
        data_directory: /pgDATA/data
        description: Primary PostgreSQL Server Backup
        disabled: False
        errors_directory: /var/lib/barman/pgbackups/primarypostgresql15/errors
        forward_config_path: False
        has_backup_privileges: True
        hba_file: /pgDATA/data/pg_hba.conf
        hot_standby: on
        ident_file: /pgDATA/data/pg_ident.conf
        immediate_checkpoint: False
        incoming_wals_directory: /var/lib/barman/pgbackups/primarypostgresql15/incoming
        is_in_recovery: False
        is_superuser: True
        last_backup_maximum_age: None
        last_backup_minimum_size: None
        last_wal_maximum_age: None
        max_incoming_wals_queue: None
        max_replication_slots: 10
        max_wal_senders: 10
        minimum_redundancy: 0
        msg_list: []
        name: primarypostgresql15
        network_compression: False
        parallel_jobs: 4
        passive_node: False
        path_prefix: "/usr/pgsql-15/bin" # this is needed for streaming archiving, pg_walrecieve command is supplied by postgresql server binary, hence we are installing the postgresql server binary in the barman server
        pg_basebackup_bwlimit: True
        pg_basebackup_compatible: True
        pg_basebackup_installed: True
        pg_basebackup_path: /bin/pg_basebackup
        pg_basebackup_tbls_mapping: True
        pg_basebackup_version: 15.1
        pg_receivexlog_compatible: True
        pg_receivexlog_installed: True
        pg_receivexlog_path: /usr/pgsql-15/bin/pg_receivewal
        pg_receivexlog_supports_slots: True
        pg_receivexlog_synchronous: False
        pg_receivexlog_version: 15.1
        pgespresso_installed: False
        post_archive_retry_script: None
        post_archive_script: None
        post_backup_retry_script: None
        post_backup_script: None
        post_delete_retry_script: None
        post_delete_script: None
        post_recovery_retry_script: None
        post_recovery_script: None
        post_wal_delete_retry_script: None
        post_wal_delete_script: None
        postgres_systemid: 7163531269528114626
        pre_archive_retry_script: None
        pre_archive_script: None
        pre_backup_retry_script: None
        pre_backup_script: None
        pre_delete_retry_script: None
        pre_delete_script: None
        pre_recovery_retry_script: None
        pre_recovery_script: None
        pre_wal_delete_retry_script: None
        pre_wal_delete_script: None
        primary_conninfo: None
        primary_ssh_command: None
        recovery_options: RecoveryOptions([])
        recovery_staging_path: None
        replication_slot: Record(slot_name='barman', active=True, restart_lsn='0/9A000000')
        replication_slot_support: True
        retention_policy: RECOVERY WINDOW OF 4 WEEKS
        retention_policy_mode: auto
        reuse_backup: None
        server_txt_version: 15.0
        slot_name: barman
        ssh_command: None
        streaming: True
        streaming_archiver: True
        streaming_archiver_batch_size: 0
        streaming_archiver_name: barman_receive_wal
        streaming_backup_name: barman_streaming_backup
        streaming_conninfo: host=10.0.2.8 user=streaming_barman password=*REDACTED* port=5432
        streaming_supported: True
        streaming_systemid: 7163531269528114626
        streaming_wals_directory: /var/lib/barman/pgbackups/primarypostgresql15/streaming
        synchronous_standby_names: ['']
        tablespace_bandwidth_limit: None
        timeline: 1
        wal_compression: off
        wal_keep_size: 1GB
        wal_level: replica
        wal_retention_policy: MAIN
        wals_directory: /var/lib/barman/pgbackups/primarypostgresql15/wals
        xlog_segment_size: 16777216
        xlogpos: 0/9A0001C0
-bash-4.2$


What all server config were impacted by the change:

-bash-4.2$ diff prechng.out postchng.out
12c12
<         backup_directory: /var/lib/barman/primarypostgresql15
---
>         backup_directory: /var/lib/barman/pgbackups/primarypostgresql15
20c20
<         basebackups_directory: /var/lib/barman/primarypostgresql15/base
---
>         basebackups_directory: /var/lib/barman/pgbackups/primarypostgresql15/base
28c28
<         current_lsn: 0/9A0000D8
---
>         current_lsn: 0/9A0001C0
38c38
<         errors_directory: /var/lib/barman/primarypostgresql15/errors
---
>         errors_directory: /var/lib/barman/pgbackups/primarypostgresql15/errors
45c45
<         incoming_wals_directory: /var/lib/barman/primarypostgresql15/incoming
---
>         incoming_wals_directory: /var/lib/barman/pgbackups/primarypostgresql15/incoming
99c99
<         replication_slot: Record(slot_name='barman', active=False, restart_lsn='0/94000000')
---
>         replication_slot: Record(slot_name='barman', active=True, restart_lsn='0/9A000000')
115c115
<         streaming_wals_directory: /var/lib/barman/primarypostgresql15/streaming
---
>         streaming_wals_directory: /var/lib/barman/pgbackups/primarypostgresql15/streaming
123c123
<         wals_directory: /var/lib/barman/primarypostgresql15/wals
---
>         wals_directory: /var/lib/barman/pgbackups/primarypostgresql15/wals
125,127c125,126
<         xlogpos: 0/9A0000D8
< You have new mail in /var/spool/mail/barman
< -bash-4.2
---
>         xlogpos: 0/9A0001C0
> -bash-4.2$
-bash-4.2$

Confirmation of the changes: <NO CH> - No changes. <OK> - changed as expected

Line 16:         backup_directory: /var/lib/barman/primarypostgresql15 <OK>
Line 20:         barman_home: /var/lib/barman <NO CH>
Line 21:         barman_lock_directory: /var/lib/barman <NO CH>
Line 24:         basebackups_directory: /var/lib/barman/primarypostgresql15/base <OK>
Line 42:         errors_directory: /var/lib/barman/primarypostgresql15/errors <OK>
Line 49:         incoming_wals_directory: /var/lib/barman/primarypostgresql15/incoming <OK>
Line 119:         streaming_wals_directory: /var/lib/barman/primarypostgresql15/streaming <OK>
Line 127:         wals_directory: /var/lib/barman/primarypostgresql15/wals <OK>

The objective was to move the actual backup content, which occupies space to a dedicated mountpoint rather than keeping them in barman's home directory.

This seem to be achieved now.


A test backup routine:

-bash-4.2$ barman backup primarypostgresql15
Starting backup using postgres method for server primarypostgresql15 in /var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949
Backup start at LSN: 0/9C000060 (00000001000000000000009C, 00000060)
Starting backup copy via pg_basebackup for 20221228T081949
Copy done (time: 1 minute, 9 seconds)
Finalising the backup.
This is the first backup for server primarypostgresql15
WAL segments preceding the current backup have been found:
        000000010000000000000095 from server primarypostgresql15 has been removed
        000000010000000000000096 from server primarypostgresql15 has been removed
        000000010000000000000097 from server primarypostgresql15 has been removed
        000000010000000000000098 from server primarypostgresql15 has been removed
        000000010000000000000099 from server primarypostgresql15 has been removed
        00000001000000000000009A from server primarypostgresql15 has been removed
        00000001000000000000009B from server primarypostgresql15 has been removed
        00000001000000000000009C from server primarypostgresql15 has been removed
Backup size: 1.2 GiB
Backup end at LSN: 0/9E000000 (00000001000000000000009D, 00000000)
Backup completed (start time: 2022-12-28 08:19:49.192492, elapsed time: 1 minute, 10 seconds)
Processing xlog segments from streaming for primarypostgresql15
        00000001000000000000009D
You have new mail in /var/spool/mail/barman
-bash-4.2$


Verify if it created files as expected:


-bash-4.2$ barman show-backup primarypostgresql15 20221228T081949
Backup 20221228T081949:
  Server Name            : primarypostgresql15
  System Id              : 7163531269528114626
  Status                 : DONE
  PostgreSQL Version     : 150000
  PGDATA directory       : /pgDATA/data
  Base backup information:
    Disk usage           : 1.2 GiB (1.2 GiB with WALs)
    Incremental size     : 1.2 GiB (-0.00%)
    Timeline             : 1
    Begin WAL            : 00000001000000000000009D
    End WAL              : 00000001000000000000009D
    WAL number           : 1
    WAL compression ratio: 99.89%
    Begin time           : 2022-12-28 08:19:49.189472-05:00
    End time             : 2022-12-28 08:20:59.048208-05:00
    Copy time            : 1 minute, 9 seconds
    Estimated throughput : 17.2 MiB/s
    Begin Offset         : 40
    End Offset           : 0
    Begin LSN           : 0/9D000028
    End LSN             : 0/9E000000
  WAL information:
    No of files          : 0
    Disk usage           : 0 B
    Last available       : 00000001000000000000009D
  Catalog information:
    Retention Policy     : VALID
    Previous Backup      : - (this is the oldest base backup)
    Next Backup          : - (this is the latest base backup)
-bash-4.2$
-bash-4.2$ barman list-files primarypostgresql15 20221228T081949
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/backup.info
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/PG_VERSION
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/backup_label
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/backup_manifest
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/current_logfiles
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/pg_hba.conf
...
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/pg_multixact/offsets/0000
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/base/1/112
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/base/1/113
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/base/1/1247
...
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/base/24605/827
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/base/24605/828
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/base/24605/PG_VERSION
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/base/24605/pg_filenode.map
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/pg_xact/0000
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/pg_logical/replorigin_checkpoint
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/log/postgresql-Fri.log
...
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/log/postgresql-Thu.log
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/log/postgresql-Tue.log
/var/lib/barman/pgbackups/primarypostgresql15/base/20221228T081949/data/log/postgresql-Wed.log
/var/lib/barman/pgbackups/primarypostgresql15/wals/0000000100000000/00000001000000000000009D

Final check:


-bash-4.2$ barman list-files primarypostgresql15 20221228T081949|wc -l
1611
You have new mail in /var/spool/mail/barman
-bash-4.2$ barman list-files primarypostgresql15 20221228T081949|grep "/var/lib/barman/pgbackups/primarypostgresql15"|wc -l
1611
-bash-4.2$


As we expected all the files were backedup on the /var/lib/barman/pgbackups/primarypostgresql15 directory.


This closes the blog.


Thank you!

Wednesday, December 14, 2022

Backup postgresql in windows using barman in linux

 Objective: Configure windows postgresql DB backup using linux Barman server

Steps first:
Step1) Collect the postgresql DB server details
Step2) Identify the barman server where the backup will be configured
Step3) Ensure you have access to both the servers - postgres and barman
Step4) Decide on the backup retention policy or collect it
Step5) Verify the version of the postgresql installed on the postgresql server
Step6) Verify that both the postgres and barman server has postgres and epel repos available
Step7) Verify if the user postgres and barman are available in the barman server - if yes, the binary for barman and postgres might have already been installed in the barman server
Step8) Verify the barman rpms are installed already on the barman server (barman-cli, barman, python3-barman, rsync etc..)
Step9) Create barman (superuser,replication) and streaming_barman (replication) user on the postgresql server
Step10) Verify the barman and streaming_barman user exists in the postgresql server
Step11) Setup passwordless ssh between the postgresql server and the barman server (postgres -> barman user) - Mandatory. Reverse for now is optional.
Step12) As root, edit the /etc/barman.conf file to include below listed config setting... in barman server

####begin
[root@10 ~]# grep -Ev ";|^$" /etc/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
parallel_jobs = 4
#last_backup_maximum_age = 1 DAYS
#retention_policy = RECOVERY WINDOW OF 1 WEEKS
####end

Step13) As root (ensure the candidate file has r permission to barman user), create server specific configuration file in barman server  
/etc/barman.d/Primary-Windows-Postgresql.conf

####begin
[Primary-Windows-Postgresql]
description = "Primary-Windows-Postgresql 15 DB Server"
conninfo = host=<ip/hostname> user=barman password=<barman_password> dbname=postgres port=5432
streaming_conninfo = host=<ip/hostname> user=streaming_barman password=<streaming_barman_password> port=5432
#if_linux#ssh_command = ssh postgres@10.0.2.8
backup_method = postgres
streaming_archiver = on
slot_name = barman
create_slot = auto
path_prefix = "/usr/pgsql-12/bin"
retention_policy = RECOVERY WINDOW OF 7 days
#archiver = on ## keep this commented for windows, we have streaming_archiver anyway
####end

Step14) Verify the config files once
Step15) Make the below changes in postgresql.conf in $PGDATA directory in the postgresql db server

wal_level = replica
archive_mode = on
#archive_command = 'rsync -a %p barman@<servername>:/var/lib/barman/Primary-Windows-Postgresql/streaming/%f'


archive_command needs to be set properly, if not set we will face an issue. You will see this in actual execution

Step16) Make the below changes in pg_hba.conf file in the $PGDATA directory in the postgresql server

host all barman <barmanserver/ip>/32 trust
host all streaming_barman <barmanserver/ip>/32 trust

Step17) coordinate with application team for an outage and restart the postgresql service once in the postgresql server
Step18) Check in the outage the output & verify the results are ok in the barman server
barman check Primary-Windows-Postgresql
barman list-backup Primary-Windows-Postgresql
Step19) Bring the application back online in case any
Step20) Verify the capacity of the /var/lib/barman and compare it against the DB capacity
Step21) Schedule the backup in cron, after creating necessary directory /var/lib/barman/backupscr/log as barman in barman server 

/usr/bin/barman backup Primary-Windows-Postgresql 1> /var/lib/barman/backupscr/log/barman_full_backup_Primary-Windows-Postgresql_$(date +\%d\%m\%y%_\%H\%M\%S).log 2>&1

Step22) Verify the successful backup

Now actual execution:

Step1) Collect the postgresql DB server details

VAGRANT|10.0.2.5

Step2) Identify the barman server where the backup will be configured

localhost.localdomain|10.0.2.9

Step3) Ensure you have access to both the servers - postgres and barman

Yes we do

Step4) Decide on the backup retention policy or collect it

1 week

Step5) Verify the version of the postgresql installed on the postgresql server

postgresql 14.6.1

Step6) Verify that both the postgres and barman server has postgres and epel repos available

postgres server is windows
barman has all the repos.

Step7) Verify if the user postgres and barman are available in the barman server - if yes, the binary for barman and postgres might have already been installed in the barman server

-bash-4.2$ id barman
uid=996(barman) gid=994(barman) groups=994(barman)
-bash-4.2$ id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)
-bash-4.2$

Step8) Verify the barman rpms are installed already on the barman server (barman-cli, barman, python3-barman, rsync etc..)

-bash-4.2$ rpm -qa|grep -i barman
barman-3.2.0-1.rhel7.noarch
python-barman-3.2.0-1.rhel7.noarch
-bash-4.2$

Step9) Create barman (superuser,replication) and streaming_barman (replication) user on the postgresql server

postgres=# \du
                                       List of roles
    Role name     |                         Attributes                         | Member of
------------------+------------------------------------------------------------+-----------
 barman           | Superuser, Replication                                     | {}
 postgres         | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 streaming_barman | Replication                                                | {}


postgres=#

Step10) Verify the barman and streaming_barman user exists in the postgresql server

Allset as we see in last step.

Step11) Setup passwordless ssh between the postgresql server and the barman server (postgres -> barman user) - Mandatory. Reverse for now is optional.

NA for windows

Step12) As root, edit the /etc/barman.conf file to include below listed config setting... in barman server

####begin
-bash-4.2$ cat barman.conf|grep -Ev "^$|^;"
[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 = pigz
parallel_jobs = 4
retention_policy = RECOVERY WINDOW OF 4 WEEKS
-bash-4.2$
####end

Step13) As root (ensure the candidate file has r permission to barman user), create server specific configuration file in barman server 

/etc/barman.d/Primary-Windows-Postgresql.conf

####begin
[Primary-Windows-Postgresql]
description = "Primary-Windows-Postgresql 15 DB Server"
conninfo = host=<ip/hostname> user=barman password=<barman_password> dbname=postgres port=5432
streaming_conninfo = host=<ip/hostname> user=streaming_barman password=<streaming_barman_password> port=5432
#if_linux#ssh_command = ssh postgres@10.0.2.8
backup_method = postgres
streaming_archiver = on
slot_name = barman
create_slot = auto
path_prefix = "/usr/pgsql-12/bin"
retention_policy = RECOVERY WINDOW OF 7 days
#archiver = on
####end


Step14) Verify the config files once

Allset

Step15) Make the below changes in postgresql.conf in $PGDATA directory in the postgresql db server

wal_level = replica
archive_mode = on
#archive_command = 'rsync -a %p barman@<servername>:/var/lib/barman/Primary-Windows-Postgresql/streaming/%f'

We are missing archive_command here, see what happens during backup

Step16) Make the below changes in pg_hba.conf file in the $PGDATA directory in the postgresql server

host    all barman              10.0.2.9/32 trust
host    all streaming_barman    10.0.2.9/32 trust

Step17) coordinate with application team for an outage and restart the postgresql service once in the postgresql server

>done

Step18) Check in the outage the output & verify the results are ok in the barman server

barman check Primary-Windows-Postgresql
barman list-backup Primary-Windows-Postgresql

-bash-4.2$ barman check Primary-Windows-Postgresql
Server Primary-Windows-Postgresql:
        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)
        backup minimum size: OK (0 B)
        wal maximum age: OK (no last_wal_maximum_age provided)
        wal size: OK (0 B)
        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: OK
        pg_receivexlog compatible: OK
        receive-wal running: OK
        archiver errors: OK
-bash-4.2$

Step19) Bring the application back online in case any

Step29) Fire an adhoc backup and check...
==========

The backup got stuck for ever, due to archive_Command comment out in postgres db server...

-bash-4.2$ barman backup Primary-Windows-Postgresql
Starting backup using postgres method for server Primary-Windows-Postgresql in /var/lib/barman/Primary-Windows-Postgresql/base/20221214T161132
Backup start at LSN: 0/2000060 (000000010000000000000002, 00000060)
Starting backup copy via pg_basebackup for 20221214T161132
....
Wait
....
Wait
....

psql - pg_stat_activity:

-[ RECORD 4 ]----+-------------------------------------------------------------------------
datid            |
datname          |
pid              | 3888
leader_pid       |
usesysid         | 16395
usename          | streaming_barman
application_name | barman_streaming_backup
client_addr      | 10.0.2.9
client_hostname  |
client_port      | 58826
backend_start    | 2022-12-14 13:11:29.76526-08
xact_start       |
query_start      | 2022-12-14 13:11:29.784469-08
state_change     | 2022-12-14 13:11:29.78448-08
wait_event_type  | IPC
wait_event       | BackupWaitWalArchive
state            | active
backend_xid      |
backend_xmin     |
query_id         |
query            | BASE_BACKUP  LABEL 'pg_basebackup base backup'  PROGRESS  MANIFEST 'yes'
backend_type     | walsender
-[ RECORD 5 ]----+-------------------------------------------------------------------------

see BackupWaitWalArchive, we are waiting for wal archive to finish in primary windows machine, but there is no archive_command, since commented it out!!!

Related info message can be seen in barman.log as well...

2022-12-14 16:28:52,336 [4346] barman.backup_executor INFO: WARNING:  still waiting for all required WAL segments to be archived (960 seconds elapsed)
2022-12-14 16:28:52,337 [4346] barman.backup_executor INFO: HINT:  Check that your archive_command is executing properly.  You can safely cancel this backup, but the database backup will not be usable without all the WAL segments.


Fix: is to introduce the archive_command with the below attribute, restart the postgresql. The backup just finished fine :)

archive_command = 'copy "%p" "C:\\Users\\Administrator\\PostgreSQL\\14\\data\\pg_archive\\%f"'


-bash-4.2$ barman backup Primary-Windows-Postgresql
Starting backup using postgres method for server Primary-Windows-Postgresql in /var/lib/barman/Primary-Windows-Postgresql/base/20221214T163834
Backup start at LSN: 0/60000D8 (000000010000000000000006, 000000D8)
Starting backup copy via pg_basebackup for 20221214T163834
Copy done (time: 1 minute, 17 seconds)
Finalising the backup.
This is the first backup for server Primary-Windows-Postgresql
WAL segments preceding the current backup have been found:
        000000010000000000000002 from server Primary-Windows-Postgresql has been removed
        000000010000000000000003 from server Primary-Windows-Postgresql has been removed
        000000010000000000000004 from server Primary-Windows-Postgresql has been removed
        000000010000000000000005 from server Primary-Windows-Postgresql has been removed
        000000010000000000000006 from server Primary-Windows-Postgresql has been removed
Backup size: 121.4 MiB
Backup end at LSN: 0/8000060 (000000010000000000000008, 00000060)
Backup completed (start time: 2022-12-14 16:38:34.640789, elapsed time: 1 minute, 20 seconds)
Processing xlog segments from streaming for Primary-Windows-Postgresql
        000000010000000000000007
        000000010000000000000008
You have new mail in /var/spool/mail/barman
-bash-4.2$

-bash-4.2$ barman list-backup Primary-Windows-Postgresql
Primary-Windows-Postgresql 20221214T163834 - Wed Dec 14 13:39:50 2022 - Size: 121.4 MiB - WAL Size: 0 B
Primary-Windows-Postgresql 20221214T161132 - FAILED
-bash-4.2

Earlier cancelled or failed one: 20221214T161132
Successful latest one: 20221214T163834

-bash-4.2$ barman show-backup Primary-Windows-Postgresql 20221214T163834
Backup 20221214T163834:
  Server Name            : Primary-Windows-Postgresql
  System Id              : 7167807434816183596
  Status                 : DONE
  PostgreSQL Version     : 140006
  PGDATA directory       : C:/Users/Administrator/PostgreSQL/14/data

  Base backup information:
    Disk usage           : 121.4 MiB (121.4 MiB with WALs)
    Incremental size     : 121.4 MiB (-0.00%)
    Timeline             : 1
    Begin WAL            : 000000010000000000000007
    End WAL              : 000000010000000000000008
    WAL number           : 2
    WAL compression ratio: 99.89%
    Begin time           : 2022-12-14 13:38:33.171758-08:00
    End time             : 2022-12-14 13:39:50.066436-08:00
    Copy time            : 1 minute, 17 seconds
    Estimated throughput : 1.6 MiB/s
    Begin Offset         : 96
    End Offset           : 96
    Begin LSN           : 0/7000060
    End LSN             : 0/8000060

  WAL information:
    No of files          : 0
    Disk usage           : 0 B
    WAL rate             : 1105.99/hour
    Last available       : 000000010000000000000008

  Catalog information:
    Retention Policy     : VALID
    Previous Backup      : - (this is the oldest base backup)
    Next Backup          : - (this is the latest base backup)
-bash-4.2$


Please note I used postgresql 15 binary in barman to backup postgresql 14.6.1 in windows.

All set!!
All the best & thank you for your visit!

Tuesday, October 25, 2022

postgresql physical backup - BARMAN

Objective: In this blog, we will examine the steps involved in barman backup configuration.



BARMAN has to be installed in a seperate server than the postgresql server.
Since my machine is very small in size, I installed barman on the same machine as postgresql server.
As per instruction from https://www.digitalocean.com/community/tutorials/how-to-back-up-restore-and-migrate-postgresql-databases-with-barman-on-centos-7
We already have postgresql server installed (version 15). Also we have epel and postgresql yum repos needed for this install step (see the packages downloaded were from either base, epel or pgdg-common).
We just need to install barman using yum install...

Actual output:

[root@10 ~]# yum install barman
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                               | 6.1 kB  00:00:00
 * base: centos.excellmedia.net
 * epel: mirrors.bestthaihost.com
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
base                                                                                               | 3.6 kB  00:00:00
epel                                                                                               | 4.7 kB  00:00:00
extras                                                                                             | 2.9 kB  00:00:00
pgdg-common/7/x86_64/signature                                                                     |  198 B  00:00:00
pgdg-common/7/x86_64/signature                                                                     | 2.9 kB  00:00:00 !!!
pgdg10/7/x86_64/signature                                                                          |  198 B  00:00:00
pgdg10/7/x86_64/signature                                                                          | 3.6 kB  00:00:00 !!!
pgdg11/7/x86_64/signature                                                                          |  198 B  00:00:00
pgdg11/7/x86_64/signature                                                                          | 3.6 kB  00:00:00 !!!
pgdg12/7/x86_64/signature                                                                          |  198 B  00:00:00
pgdg12/7/x86_64/signature                                                                          | 3.6 kB  00:00:00 !!!
pgdg13/7/x86_64/signature                                                                          |  198 B  00:00:00
pgdg13/7/x86_64/signature                                                                          | 3.6 kB  00:00:00 !!!
pgdg14/7/x86_64/signature                                                                          |  198 B  00:00:00
pgdg14/7/x86_64/signature                                                                          | 3.6 kB  00:00:00 !!!
pgdg15/7/x86_64/signature                                                                          |  198 B  00:00:00
pgdg15/7/x86_64/signature                                                                          | 3.6 kB  00:00:00 !!!
updates                                                                                            | 2.9 kB  00:00:00
(1/8): pgdg10/7/x86_64/primary_db                                                                  | 396 kB  00:00:12
(2/8): pgdg11/7/x86_64/primary_db                                                                  | 440 kB  00:00:13
(3/8): pgdg13/7/x86_64/primary_db                                                                  | 224 kB  00:00:02
(4/8): pgdg14/7/x86_64/primary_db                                                                  | 146 kB  00:00:01
(5/8): pgdg15/7/x86_64/primary_db                                                                  |  56 kB  00:00:00
(6/8): pgdg12/7/x86_64/primary_db                                                                  | 326 kB  00:00:17
(7/8): epel/x86_64/primary_db                                                                      | 7.0 MB  00:00:29
(8/8): epel/x86_64/updateinfo                                                                      | 1.0 MB  00:04:03
Resolving Dependencies
--> Running transaction check
---> Package barman.noarch 0:3.2.0-1.rhel7 will be installed
--> Processing Dependency: python-barman = 3.2.0 for package: barman-3.2.0-1.rhel7.noarch
--> Processing Dependency: rsync >= 3.0.4 for package: barman-3.2.0-1.rhel7.noarch
--> Running transaction check
---> Package python-barman.noarch 0:3.2.0-1.rhel7 will be installed
--> Processing Dependency: python-psycopg2 >= 2.4.2 for package: python-barman-3.2.0-1.rhel7.noarch
--> Processing Dependency: python-setuptools for package: python-barman-3.2.0-1.rhel7.noarch
--> Processing Dependency: python-dateutil for package: python-barman-3.2.0-1.rhel7.noarch
--> Processing Dependency: python-argcomplete for package: python-barman-3.2.0-1.rhel7.noarch
---> Package rsync.x86_64 0:3.1.2-11.el7_9 will be installed
--> Running transaction check
---> Package python-dateutil.noarch 0:1.5-7.el7 will be installed
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
---> Package python2-argcomplete.noarch 0:1.7.0-4.el7 will be installed
---> Package python2-psycopg2.x86_64 0:2.8.6-1.rhel7 will be installed
--> Running transaction check
---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed
--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================
 Package                                        Arch              Version                    Repository              Size
==========================================================================================================================
Installing:
 barman                                         noarch            3.2.0-1.rhel7              pgdg-common             44 k
Installing for dependencies:
 python-backports                               x86_64            1.0-8.el7                  base                   5.8 k
 python-backports-ssl_match_hostname            noarch            3.5.0.1-1.el7              base                    13 k
 python-barman                                  noarch            3.2.0-1.rhel7              pgdg-common            451 k
 python-dateutil                                noarch            1.5-7.el7                  base                    85 k
 python-ipaddress                               noarch            1.0.16-2.el7               base                    34 k
 python-setuptools                              noarch            0.9.8-7.el7                base                   397 k
 python2-argcomplete                            noarch            1.7.0-4.el7                epel                    49 k
 python2-psycopg2                               x86_64            2.8.6-1.rhel7              pgdg-common            171 k
 rsync                                          x86_64            3.1.2-11.el7_9             updates                408 k
Transaction Summary
==========================================================================================================================
Install  1 Package (+9 Dependent packages)
Total download size: 1.6 M
Installed size: 6.5 M
Is this ok [y/d/N]: y
Downloading packages:
(1/10): python-backports-1.0-8.el7.x86_64.rpm                                                      | 5.8 kB  00:00:06
(2/10): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm                               |  13 kB  00:00:06
(3/10): python-dateutil-1.5-7.el7.noarch.rpm                                                       |  85 kB  00:00:07
(4/10): barman-3.2.0-1.rhel7.noarch.rpm                                                            |  44 kB  00:00:08
(5/10): python2-psycopg2-2.8.6-1.rhel7.x86_64.rpm                                                  | 171 kB  00:00:04
(6/10): python-ipaddress-1.0.16-2.el7.noarch.rpm                                                   |  34 kB  00:00:06
(7/10): python-setuptools-0.9.8-7.el7.noarch.rpm                                                   | 397 kB  00:00:08
(8/10): python-barman-3.2.0-1.rhel7.noarch.rpm                                                     | 451 kB  00:00:16
(9/10): python2-argcomplete-1.7.0-4.el7.noarch.rpm                                                 |  49 kB  00:00:08
(10/10): rsync-3.1.2-11.el7_9.x86_64.rpm                                                           | 408 kB  00:00:06
--------------------------------------------------------------------------------------------------------------------------
Total                                                                                      84 kB/s | 1.6 MB  00:00:19
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python2-psycopg2-2.8.6-1.rhel7.x86_64                                                                 1/10
  Installing : python-ipaddress-1.0.16-2.el7.noarch                                                                  2/10
  Installing : python-backports-1.0-8.el7.x86_64                                                                     3/10
  Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                              4/10
  Installing : python-setuptools-0.9.8-7.el7.noarch                                                                  5/10
  Installing : python2-argcomplete-1.7.0-4.el7.noarch                                                                6/10
  Installing : python-dateutil-1.5-7.el7.noarch                                                                      7/10
  Installing : python-barman-3.2.0-1.rhel7.noarch                                                                    8/10
  Installing : rsync-3.1.2-11.el7_9.x86_64                                                                           9/10
  Installing : barman-3.2.0-1.rhel7.noarch                                                                          10/10
  Verifying  : rsync-3.1.2-11.el7_9.x86_64                                                                           1/10
  Verifying  : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                              2/10
  Verifying  : python-dateutil-1.5-7.el7.noarch                                                                      3/10
  Verifying  : python2-argcomplete-1.7.0-4.el7.noarch                                                                4/10
  Verifying  : barman-3.2.0-1.rhel7.noarch                                                                           5/10
  Verifying  : python-backports-1.0-8.el7.x86_64                                                                     6/10
  Verifying  : python-ipaddress-1.0.16-2.el7.noarch                                                                  7/10
  Verifying  : python2-psycopg2-2.8.6-1.rhel7.x86_64                                                                 8/10
  Verifying  : python-barman-3.2.0-1.rhel7.noarch                                                                    9/10
  Verifying  : python-setuptools-0.9.8-7.el7.noarch                                                                 10/10
Installed:
  barman.noarch 0:3.2.0-1.rhel7
Dependency Installed:
  python-backports.x86_64 0:1.0-8.el7                python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7
  python-barman.noarch 0:3.2.0-1.rhel7               python-dateutil.noarch 0:1.5-7.el7
  python-ipaddress.noarch 0:1.0.16-2.el7             python-setuptools.noarch 0:0.9.8-7.el7
  python2-argcomplete.noarch 0:1.7.0-4.el7           python2-psycopg2.x86_64 0:2.8.6-1.rhel7
  rsync.x86_64 0:3.1.2-11.el7_9
Complete!

[root@10 ~]# id barman
uid=998(barman) gid=996(barman) groups=996(barman)
[root@10 ~]#

We alrady have the pg_hba.conf with the below entry, this means that connections coming from 127.0.0.1/32 with all users by default will be allowed without password prompt.

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust

Let us setup passwordless ssh setup between barman and postgres user...
The passwordless was setup using the below command

ssh-keygen -t rsa

The command has to be run as both postgres and barman user. The .pub key of both the users needs to be put into authorized_keys file of the .ssh directories of the corresponding user.

Still I faced issues with postgres user (postgres user's password was always prompted), mistake I made was I copied authorized_keys file from barman, it messed up my selinux context for ever... I try remove and readd of the authorized_keys file in the user home. The issue was still the same.

Later I ran the below set of command as postgres user

chmod 755 /var/lib/pgsql/.ssh
chmod 600 /var/lib/pgsql/.ssh/authorized_keys
restorecon -R -v /var/lib/pgsql/.ssh

Now the passwordless ssh worked fine.
Now we need to update /etc/barman.conf, which is at the moment owned by root.
So if in case we have sudo setup for barman we can use it or login as root to perform the below operation....


[barman]
compression = gzip
immediate_checkpoint = false
basebackup_retry_times = 3
basebackup_retry_sleep = 30
last_backup_maximum_age = 1 DAYS
[per postgres instance]
description = "Main Postgres1l 15 DB Server"
ssh_command = ssh postgres@127.0.0.1
conninfo = host=127.0.0.1 user=postgres
retention_policy_mode = auto
retention_policy = RECOVERY WINDOW OF 7 days
wal_retention_policy = main

>>>> configuration @ barman side is complete. Final config values are...

[root@10 ~]# grep -Ev ";|^$" /etc/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 = false
basebackup_retry_times = 3
basebackup_retry_sleep = 30
last_backup_maximum_age = 1 DAYS
[postgres15-dbserver]
description = "Main Postgres1l 15 DB Server"
ssh_command = ssh postgres@127.0.0.1
conninfo = host=127.0.0.1 user=postgres
retention_policy_mode = auto
retention_policy = RECOVERY WINDOW OF 7 days
wal_retention_policy = main
[root@10 ~]#

Find out the incoming_wals_directory:
barman show-server postgres15-dbserver | grep incoming_wals_directory

Actual output:

-bash-4.2$ barman show-server postgres15-dbserver | grep incoming_wals_directory
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
        incoming_wals_directory: /var/lib/barman/postgres15-dbserver/incoming
-bash-4.2$

Now changed the postgresql.conf with the below setting & restarted postgresql service:

-bash-4.2$ grep -E "wal_level|archive_mode|archive_command" postgresql.conf
wal_level = replica                     # minimal, replica, or logical
archive_mode = on               # enables archiving; off, on, or always
                                # (empty string indicates archive_command should
archive_command = 'rsync -a %p barman@127.0.0.1:/var/lib/barman/postgres15-dbserver/incoming/%f'                # command to use to archive a logfile segment
-bash-4.2$

[root@10 ~]# systemctl restart postgresql-15
[root@10 ~]# systemctl status postgresql-15
● postgresql-15.service - PostgreSQL 15 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/postgresql-15.service.d
           └─override.conf
   Active: active (running) since Tue 2022-10-25 22:06:25 IST; 6s ago
     Docs: https://www.postgresql.org/docs/15/static/
  Process: 1985 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 1990 (postmaster)
   CGroup: /system.slice/postgresql-15.service
           ├─1990 /usr/pgsql-15/bin/postmaster -D /pgDATA/data
           ├─1992 postgres: logger
           ├─1993 postgres: checkpointer
           ├─1994 postgres: background writer
           ├─1996 postgres: walwriter
           ├─1997 postgres: autovacuum launcher
           ├─1998 postgres: archiver
           └─1999 postgres: logical replication launcher
Oct 25 22:06:24 10.0.2.4 systemd[1]: Stopped PostgreSQL 15 database server.
Oct 25 22:06:24 10.0.2.4 systemd[1]: Starting PostgreSQL 15 database server...
Oct 25 22:06:25 10.0.2.4 postmaster[1990]: 2022-10-25 22:06:25.210 IST [1990] LOG:  redirecting log output to logg...ocess
Oct 25 22:06:25 10.0.2.4 postmaster[1990]: 2022-10-25 22:06:25.210 IST [1990] HINT:  Future log output will appear...log".
Oct 25 22:06:25 10.0.2.4 systemd[1]: Started PostgreSQL 15 database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@10 ~]#

BARMAN check:

command: barman check postgres15-dbserver
-bash-4.2$ barman check postgres15-dbserver
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
Server postgres15-dbserver:
        WAL archive: FAILED (please make sure WAL shipping is setup) <<<<<<<<<< To work around this error, we have to run the next command.
        PostgreSQL: OK
        superuser or standard user with backup privileges: OK
        wal_level: OK
        directories: OK
        retention policy settings: OK
        backup maximum age: FAILED (interval provided: 1 day, latest backup age: No available backups)
        backup minimum size: OK (0 B)
        wal maximum age: OK (no last_wal_maximum_age provided)
        wal size: OK (0 B)
        compression settings: OK
        failed backups: OK (there are 0 failed backups)
        minimum redundancy requirements: OK (have 0 backups, expected at least 0)
        ssh: OK (PostgreSQL server)
        systemid coherence: OK (no system Id stored on disk)
        archive_mode: OK
        archive_command: OK
        continuous archiving: OK
        archiver errors: OK
-bash-4.2$

I have kept irewalld down for now.

barman switch-wal --force --archive postgres15-dbserver

Actual output:

-bash-4.2$  barman switch-wal --force --archive postgres15-dbserver
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
The WAL file 000000010000000100000000 has been closed on server 'postgres15-dbserver'
Waiting for the WAL file 000000010000000100000000 from server 'postgres15-dbserver' (max: 30 seconds)
Processing xlog segments from file archival for postgres15-dbserver
        000000010000000100000000

>>>> the switch-wal finished fine.

-bash-4.2$ barman check postgres15-dbserver
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
Server postgres15-dbserver:
        PostgreSQL: OK <<<< No more error or warnings.
        superuser or standard user with backup privileges: OK
        wal_level: OK
        directories: OK
        retention policy settings: OK
        backup maximum age: FAILED (interval provided: 1 day, latest backup age: No available backups)
        backup minimum size: OK (0 B)
        wal maximum age: OK (no last_wal_maximum_age provided)
        wal size: OK (0 B)
        compression settings: OK
        failed backups: OK (there are 0 failed backups)
        minimum redundancy requirements: OK (have 0 backups, expected at least 0)
        ssh: OK (PostgreSQL server)
        systemid coherence: OK (no system Id stored on disk)
        archive_mode: OK
        archive_command: OK
        continuous archiving: OK
        archiver errors: OK
-bash-4.2$

barman list-server

Actual output:

-bash-4.2$ barman list-server
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
postgres15-dbserver - Main Postgres1l 15 DB Server
-bash-4.2$

Creating the first backup:

barman backup postgres15-dbserver

Actual output:

-bash-4.2$ barman backup postgres15-dbserver
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
Starting backup using rsync-concurrent method for server postgres15-dbserver in /var/lib/barman/postgres15-dbserver/base/20221025T233915
Backup start at LSN: 1/2000028 (000000010000000100000002, 00000028)
This is the first backup for server postgres15-dbserver
WAL segments preceding the current backup have been found:
        0000000100000000000000FD from server postgres15-dbserver has been removed
        0000000100000000000000FE from server postgres15-dbserver has been removed
        0000000100000000000000FF from server postgres15-dbserver has been removed
        000000010000000100000000 from server postgres15-dbserver has been removed
Starting backup copy via rsync/SSH for 20221025T233915
Copy done (time: 1 minute, 52 seconds)
This is the first backup for server postgres15-dbserver
WAL segments preceding the current backup have been found:
        000000010000000100000001 from server postgres15-dbserver has been removed
Asking PostgreSQL server to finalize the backup.
Backup size: 2.1 GiB
Backup end at LSN: 1/2000170 (000000010000000100000002, 00000170)
Backup completed (start time: 2022-10-25 23:39:15.563684, elapsed time: 2 minutes, 1 second)
Processing xlog segments from file archival for postgres15-dbserver
        000000010000000100000002
        000000010000000100000002.00000028.backup
        000000010000000100000003
-bash-4.2$

barman list-backup postgres15-dbserver

Actual output:

-bash-4.2$ barman list-backup postgres15-dbserver
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
postgres15-dbserver 20221025T233915 - Tue Oct 25 23:41:11 2022 - Size: 2.1 GiB - WAL Size: 16.0 KiB
-bash-4.2$
barman list-files postgres15-dbserver 20221025T233915
Actual output:
-bash-4.2$ barman list-files postgres15-dbserver 20221025T233915
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
/var/lib/barman/postgres15-dbserver/base/20221025T233915/backup.info
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/PG_VERSION
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/backup_label
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/current_logfiles
...
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/global/6247
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/global/pg_control
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/global/pg_filenode.map
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/pg_logical/replorigin_checkpoint
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/pg_multixact/members/0000
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/pg_multixact/offsets/0000
/var/lib/barman/postgres15-dbserver/base/20221025T233915/data/pg_xact/0000
/var/lib/barman/postgres15-dbserver/wals/0000000100000001/000000010000000100000002
-bash-4.2$
After last backup no more FAILED state in check output of barman.
-bash-4.2$ barman check postgres15-dbserver
WARNING: No backup strategy set for server 'postgres15-dbserver' (using default 'concurrent_backup').
WARNING: No archiver enabled for server 'postgres15-dbserver'. Please turn on 'archiver', 'streaming_archiver' or both
WARNING: Forcing 'archiver = on'
Server postgres15-dbserver:
        PostgreSQL: OK
        superuser or standard user with backup privileges: OK
        wal_level: OK
        directories: OK
        retention policy settings: OK
        backup maximum age: OK (interval provided: 1 day, latest backup age: 8 minutes, 34 seconds)
        backup minimum size: OK (2.1 GiB)
        wal maximum age: OK (no last_wal_maximum_age provided)
        wal size: OK (16.0 KiB)
        compression settings: OK
        failed backups: OK (there are 0 failed backups)
        minimum redundancy requirements: OK (have 1 backups, expected at least 0)
        ssh: OK (PostgreSQL server)
        systemid coherence: OK
        archive_mode: OK
        archive_command: OK
        continuous archiving: OK
        archiver errors: OK
-bash-4.2$

This completes barman backup. We have to schedule regular backup in cron of barman.
Thanks

OKV platform certificate rotation - pitfall , awareness!!!!

OKV version: 21.9 Setup: Multimaster R/W cluster Plan: https://docs.google.com/spreadsheets/d/e/2PACX-1vSaXXTjj9cE1fvYpNmsDNBOkTIw78yTwQ6a9o...