How to Upgrade Carbonio Community Edition to PostgreSQL 16 in Ubuntu 20.04 | Carbonio CE

The latest Carbonio CE 24.03 update adds support for PostgreSQL 16. Those who previously installed Carbonio on Ubuntu 20.04 using PostgreSQL 12 were faced with the need to update the distribution and version of PostgreSQL they were using to the current version. In this instruction, we will tell you how to do this.

If you intend to upgrade PostgreSQL before upgrading to the Ubuntu 22.04 version, the upgrade process will be different from the standard one.

First of all, you will need to install the appropriate repository and the key for it:

sh -c 'echo "deb $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - | sudo apt-key add -

After adding the repository, update the list of available packages and update to PostgreSQL 16

apt update
apt -y install postgresql-16

Migrate data from PostgreSQL 12 to PostgreSQL 16. To do this:

  • Check the list of installed PostgreSQL clusters – pg_lsclusters
  • Stop PostgreSQL – systemctl stop postgresql
  • Rename the default PostgreSQL cluster created – pg_renamecluster 16 main main_pristine
  • Upgrade your cluster to version 16 – pg_upgradecluster 12 main
  • Boot PostgreSQL – systemctl start postgresql
  • Verify that the PostgreSQL cluster has become the default – pg_lsclusters

Verify that all databases have moved to the new cluster.

su - postgres

If at any stage of the instructions an error occurred due to the port being busy and the database migration did not take place, please refer to the section “Problems Updating PostgreSQL

If the cluster used is PostgreSQL 16 and it displays a complete list of databases, the migration was successful and you can delete unused clusters.

  • Delete a cluster PostgreSQL 12 – pg_dropcluster 12 main --stop
  • Removing a backup cluster PostgreSQL 16 – pg_dropcluster 16 main_pristine --stop

During the PostgreSQL update process, an error may occur due to a port conflict.

Error: Port conflict: another instance is already running on /var/run/postgresql with port 5432
Error: Could not start target cluster

This error is reproduced even if the PostgreSQL service is stopped. If you ignore this error, all databases will be lost when migrating to a new version of PostgreSQL.

To avoid this and update, you need to change the port on which PostgreSQL runs. For this:

  • Change parameter port = 5432 to the port = 5433 in file /etc/postgresql/12/main/postgresql.conf
  • Stop PostgreSQL service – systemctl stop postgresql.service
  • Verify that no clusters are running – pg_lsclusters.
  • In case any cluster is running execute pg_ctlcluster 12 main stop command (replacing the cluster name and version with the ones that are used in your infrastructure)
  • Run again pg_upgradecluster
  • Change the used port to 5432 in the file /etc/postgresql/16/main/postgresql.conf.

Reboot PostgreSQL – systemctl restart postgresql.service

Post your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Organize Your Work with Tasks in Carbonio Community Edition | Carbonio CE
How to Upgrade Carbonio Community Edition to PostgreSQL 16 in 22.04 | Carbonio CE