In our previous PostgreSQL upgrade blog post, we have shown how to upgrade on Windows machines, and this post is valid for the newer PostgreSQL versions as well. However, this time we are focusing on Debian, as there is a little bit of difference.

PostgreSQL upgrade PostgreSQL (commonly known as Postgres) is a well-known, solid as a rock database. And yes, from time to time it craves for an upgrade too. Today we will learn something about PostgreSQL Windows upgrade from version 9.6 to 12. KEEP IN MIND: As a https://www.netvizura.com/blog/postgres-upgrade

 

KEEP IN MIND: As always, backup your database before starting any upgrade procedure.

Remember, the procedure we are going to cover now can be reused on different versions, not just 13->14. We have tested 11->14 upgrade and it worked marvelously.First, install the newer version of Postgres 14 and then execute the command below to confirm that you have multiple Postgres instances:

root@debian10:~# pg_lsclusters
Ver Cluster Port Status OwnerData directoryLog file
13main5432 online postgres /var/lib/postgresql/13/main log/postgresql-%Y-%m-%d.log
14main5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log

As we can see here, both versions 13 and 14 are currently installed and running. Bear in mind with this type of upgrade: you need double storage space because pg_upgradecluster command is copying data.

The upgrade procedure is the following:

1. Drop the newer version data:

postgres@debian10:~$ pg_dropcluster --stop 14 main

2. Start the upgradecluster procedure:

postgres@debian10:~$ pg_upgradecluster 13 main

3. Once the operation is completed, double-check whether it is working

4. Remove the old version:

postgres@debian10:~$ pg_dropcluster --stop 13 main

This pretty much illustrates a different way to upgrade the cluster. Of course, there are numerous options with upgradecluster command- from version number to folder where it will store new data. However, this is maybe a topic for another blog post. Stay tuned.