This article shows what actions are needed in Barman after a major PostgreSQL upgrade has been performed. In this scenario, we will utilize Barman 3.10
as our disaster recovery tool for EPAS 15
mounted locally on a RHEL 8
environment; to which we will upgrade EPAS 15
to EPAS 16
and then perform the necessary steps to update our Barman
server to reflect the new PostgreSQL
instance to ensure that your backups and recovery procedures remain consistent and reliable.
Before performing the steps below, the assumption will be that you already have installed and setup Enterprise Postgres Advanced Server EPAS 15
and Barman 3.10
. If you don't have those installed please click on the links below to download and install those packages.
First we need to identify our EPAS server called test
being monitored by Barman and view our Barman configuration file. We will also verify that our Barman server is fully functional by running barman check test
.
$ sudo vi test.conf
[test]
; Human readable description
description = "PG 15 UPGRADE TO 16 database"
ssh_command = ssh enterprisedb@localhost
conninfo = host=localhost user=enterprisedb dbname=edb
streaming_conninfo = host=localhost user=enterprisedb
backup_method = postgres
;reuse_backup = link
backup_options = concurrent_backup
parallel_jobs = 2
archiver = on
archiver_batch_size = 50
path_prefix = "/usr/edb/as15/bin/"
streaming_backup_name = barman_streaming_backup
streaming_archiver = on
slot_name = barman
create_slot = auto
streaming_archiver_name = barman_receive_wal
streaming_archiver_batch_size = 50
$ barman check test
Server test:
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 (55.5 MiB)
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 6 backups, expected at least 0)
pg_basebackup: OK
pg_basebackup compatible: OK
pg_basebackup supports tablespaces mapping: OK
systemid coherence: OK
pg_receivexlog: OK
pg_receivexlog compatible: OK
receive-wal running: OK
archive_mode: OK
archive_command: OK
continuous archiving: OK
archiver errors: OK
$ barman list-backups test
test 20240516T123336 - Thu May 16 12:33:38 2024 - Size: 71.5 MiB - WAL Size: 0 B
test 20240516T123333 - Thu May 16 12:33:35 2024 - Size: 71.5 MiB - WAL Size: 32.0 MiB
test 20240516T123329 - Thu May 16 12:33:31 2024 - Size: 71.5 MiB - WAL Size: 32.0 MiB
test 20240516T123326 - Thu May 16 12:33:28 2024 - Size: 71.5 MiB - WAL Size: 32.0 MiB
test 20240516T123317 - Thu May 16 12:33:19 2024 - Size: 87.5 MiB - WAL Size: 32.0 MiB
test 20240516T123256 - Thu May 16 12:32:58 2024 - Size: 71.5 MiB - WAL Size: 48.0 MiB
For this step to work, the assumption is that you have already downloaded/installed and initialized EPAS16
.
You will then perform the upgrade from EPAS15
to the new version and configure Barman
to identify the new cluster.
For more information about performing a PostgreSQL upgrade, you may refer to the official documentation.
Run the pg_upgrade
:
$ /usr/edb/as16/bin/pg_upgrade -b /usr/edb/as15/bin/ -B /usr/edb/as16/bin/ -d /var/lib/edb/as15/data/ -D /var/lib/edb/as16/data/ -v
Running in verbose mode
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking for contrib/isn with bigint-passing mismatch ok
Creating dump of global objects "/usr/edb/as16/bin/pg_dumpall" --host /var/lib/edb --port 50432 --username enterprisedb --globals-only --quote-all-identifiers --binary-upgrade --verbose -f "/var/lib/edb/as16/data/pg_upgrade_output.d/20240516T175920.077/dump/pg_upgrade_dump_globals.sql" >> "/var/lib/edb/as16/data/pg_upgrade_output.d/20240516T175920.077/log/pg_upgrade_utility.log" 2>&1
ok
Checking for presence of required libraries ok
Checking database user is the install user executing: SELECT rolsuper, oid FROM pg_catalog.pg_roles WHERE rolname = current_user AND rolname !~ '^pg_'
executing: SELECT oid FROM pg_catalog.pg_roles WHERE rolname !~ '^pg_'
ok
executing: SELECT pg_catalog.set_config('search_path', '', false);
Checking for prepared transactions executing: SELECT * FROM pg_catalog.pg_prepared_xacts
ok
Checking for new cluster tablespace directories ok
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
/usr/edb/as16/bin/vacuumdb --all --analyze-in-stages
Running this script will delete the old cluster's data files:
./delete_old_cluster.sh
Verify that data is reflecting in the newly upgraded EPAS 16 server:
$ psql -dedb
psql (16.3.0)
Type "help" for help.
edb=# \dt
List of relations
Schema | Name | Type | Owner
--------+-------+-------+--------------
public | test | table | enterprisedb
public | test2 | table | enterprisedb
(2 rows)
Update test.conf
to reflect the new EPAS
binaries:
$ sudo vi test.conf
[test]
; Human readable description
description = "PG 15 UPGRADE TO 16 database"
ssh_command = ssh enterprisedb@localhost
conninfo = host=localhost user=enterprisedb dbname=edb
streaming_conninfo = host=localhost user=enterprisedb
backup_method = postgres
;reuse_backup = link
backup_options = concurrent_backup
parallel_jobs = 2
archiver = on
archiver_batch_size = 50
path_prefix = "/usr/edb/as16/bin/" <<-------------- (Update the path prefix)
streaming_backup_name = barman_streaming_backup
streaming_archiver = on
slot_name = barman
create_slot = auto
streaming_archiver_name = barman_receive_wal
streaming_archiver_batch_size = 50
Verify new barman configuration:
$ barman check test
Server test:
[barman@localhost ~]$ barman check test
Server test:
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 (55.5 MiB)
wal maximum age: OK (no last_wal_maximum_age provided)
wal size: OK (48.0 MiB)
compression settings: OK
failed backups: OK (there are 0 failed backups)
minimum redundancy requirements: OK (have 9 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
archive_mode: OK
archive_command: OK
continuous archiving: OK
archiver errors: OK
Please note that setting up archiving for the new EPAS server is beneficial. Also, if you did not already set create_slot = auto
in your barman configuration file, you will need to run receive-wal
to start the pg_receivewal
for the new EPAS server and ensure the receive-wal running
check passesm as shown below:
barman receive-wal --create-slot test
barman cron
Refer to the official barman documentation for information on configuring your Barman server.
IMPORTANT!!: Please note that a server in Barman must refer to the same PostgreSQL instance for the whole backup and recover-ability history (i.e. the same system identifier). This means that if you perform an upgrade of the instance (using for example pg_upgrade
, you won't be able to perform PITR from a backup in version EPAS 15
to a point in time after the pg_upgrade
. So even though we didn't delete the backups from before the pg_upgrade
, those backups are only useful to restore to an EPAS 15
instance. A good practice would be to move those backups to a separate location and start with an empty backup catalog on Barman.
Now that Barman is pointing to the EPAS 16
instance, take a new backup to finish the process:
barman backup test
Make sure the backup finishes and is shown in the list of backups:
barman list-backups test