PostgreSQL minor version upgrade from 13.1 to 13.4
Current PostgreSQL version numbers consist of a major and a minor version number. For example, in version number 13.1, where 13 is the major version number and 1 is the minor version number.
Minor releases never change the internal storage format and are always compatible with earlier and later minor releases of the same major version number. For example, version 13.1 is compatible with version 13.0 and version 13.4. To perform a minor upgrade stop the database server, install the updated binaries, and restart the server.
Follow the below steps to perform a minor version upgrade:
- Take the backup of PostgreSQL cluster
- Check the current PostgreSQL version
- Check for latest available version
- Stop the PostgreSQL cluster
- Run yum update to update new binaries
- Start PostgreSQL Cluster and check Version
Step 1. Take the backup of PostgreSQL cluster: Use pg_dumpall for logical backup and pg_basebackup for physical backup.
[root@test-machine01 ~]# su - postgres
Last login: Sun Oct 10 19:12:42 +03 2021 on pts/1
[postgres@test-machine01 ~]$
[postgres@test-machine01 ~]$ pg_dumpall -U postgres -W -f /u01/backup/dumpall.sql
Password:
[postgres@test-machine01 ~]$
[postgres@test-machine01 ~]$ ls -l /u01/backup/dumpall.sql
-rw-r--r--. 1 postgres postgres 2769994 Jun 10 16:44 /u01/backup/dumpall.sql
[postgres@test-machine01 ~]$
Step 2. Check the current PostgreSQL version: Use psql command select version() to check current version of PostgreSQL Cluster.
[postgres@test-machine01 ~]$
[postgres@test-machine01 ~]$ psql
Type "help" for help.
postgres=#
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 13.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
postgres=#
postgres=#
Step 3. Check for the latest available version: To review a list of the package updates that are available for your system use OS Command yum check-update. And yum list command will show installed and available packages.
[root@test-machine01 ~]# yum check-update postgresql13*
Loaded plugins: langpacks, ulninfo
pgdg-common | 2.9 kB 00:00:00
pgdg10 | 3.6 kB 00:00:00
pgdg11 | 3.6 kB 00:00:00
pgdg12 | 3.6 kB 00:00:00
pgdg13 | 3.6 kB 00:00:00
pgdg95 | 3.6 kB 00:00:00
pgdg96 | 3.6 kB 00:00:00
postgresql13.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-libs.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-server.x86_64 13.4-1PGDG.rhel7 pgdg13
[root@test-machine01 ~]#
[root@test-machine01 ~]# yum list postgresql13*
Loaded plugins: langpacks, ulninfo
Installed Packages
postgresql13.x86_64 13.1-3PGDG.rhel7 @pgdg13
postgresql13-libs.x86_64 13.1-3PGDG.rhel7 @pgdg13
postgresql13-server.x86_64 13.1-3PGDG.rhel7 @pgdg13
Available Packages
postgresql13.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-contrib.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-devel.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-docs.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-libs.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-llvmjit.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-odbc.x86_64 13.00.0000-1PGDG.rhel7 pgdg13
postgresql13-plperl.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-plpython3.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-pltcl.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-server.x86_64 13.4-1PGDG.rhel7 pgdg13
postgresql13-test.x86_64 13.4-1PGDG.rhel7 pgdg13
[root@test-machine01 ~]#
Step 4. Stop the PostgreSQL cluster: Stop PostgreSQL Cluster using command systemctl stop
[root@test-machine01 ~]#
[root@test-machine01 ~]# systemctl stop postgresql-13
[root@test-machine01 ~]#
Step 5. Run yum update to update new binaries: Use OS command yum update to update existing binaries.
[root@test-machine01 ~]#
[root@test-machine01 ~]# yum update postgresql13*
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package postgresql13.x86_64 0:13.1-3PGDG.rhel7 will be updated
---> Package postgresql13.x86_64 0:13.4-1PGDG.rhel7 will be an update
---> Package postgresql13-libs.x86_64 0:13.1-3PGDG.rhel7 will be updated
---> Package postgresql13-libs.x86_64 0:13.4-1PGDG.rhel7 will be an update
---> Package postgresql13-server.x86_64 0:13.1-3PGDG.rhel7 will be updated
---> Package postgresql13-server.x86_64 0:13.4-1PGDG.rhel7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================
Updating:
postgresql13 x86_64 13.4-1PGDG.rhel7 pgdg13 1.4 M
postgresql13-libs x86_64 13.4-1PGDG.rhel7 pgdg13 381 k
postgresql13-server x86_64 13.4-1PGDG.rhel7 pgdg13 5.4 M
Transaction Summary
=============================================================================================================================================================================
Upgrade 3 Packages
Total download size: 7.2 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/3): postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm | 381 kB 00:00:02
(2/3): postgresql13-13.4-1PGDG.rhel7.x86_64.rpm | 1.4 MB 00:00:02
(3/3): postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm | 5.4 MB 00:00:02
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.4 MB/s | 7.2 MB 00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : postgresql13-libs-13.4-1PGDG.rhel7.x86_64 1/6
Updating : postgresql13-13.4-1PGDG.rhel7.x86_64 2/6
Updating : postgresql13-server-13.4-1PGDG.rhel7.x86_64 3/6
Cleanup : postgresql13-server-13.1-3PGDG.rhel7.x86_64 4/6
Cleanup : postgresql13-13.1-3PGDG.rhel7.x86_64 5/6
Cleanup : postgresql13-libs-13.1-3PGDG.rhel7.x86_64 6/6
Verifying : postgresql13-libs-13.4-1PGDG.rhel7.x86_64 1/6
Verifying : postgresql13-13.4-1PGDG.rhel7.x86_64 2/6
Verifying : postgresql13-server-13.4-1PGDG.rhel7.x86_64 3/6
Verifying : postgresql13-server-13.1-3PGDG.rhel7.x86_64 4/6
Verifying : postgresql13-13.1-3PGDG.rhel7.x86_64 5/6
Verifying : postgresql13-libs-13.1-3PGDG.rhel7.x86_64 6/6
Updated:
postgresql13.x86_64 0:13.4-1PGDG.rhel7 postgresql13-libs.x86_64 0:13.4-1PGDG.rhel7 postgresql13-server.x86_64 0:13.4-1PGDG.rhel7
Complete!
[root@test-machine01 ~]#
Step 6. Start PostgreSQL Cluster and check Version: Start the PostgreSQL Cluster using command systemctl start and check version. You will notice version is upgraded from 13.1 to 13.4.
[root@test-machine01 ~]#
[root@test-machine01 ~]# systemctl start postgresql-13
[root@test-machine01 ~]#
[root@test-machine01 ~]#
[root@test-machine01 ~]#
[root@test-machine01 ~]# su - postgres
Last login: Sun Oct 10 19:12:42 +03 2021 on pts/1
[postgres@test-machine01 ~]$
[postgres@test-machine01 ~]$ psql
Type "help" for help.
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 13.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
postgres=#
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/subscribeand 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
- Access the MSSQL database from PostgreSQL using TDS Foreign Data Wrapper (TDS_FDW)
- Access MySql database from PostgreSQL using MySQL Foreign Data Wrapper (MYSQL_FDW)
- Configure and monitor using pg_profile in PostgreSQL
- Monitor PostgreSQL Cluster using pgCenter
- Install and Configure pg_repack in PostgreSQL