Skip to content

Instantly share code, notes, and snippets.

@msmarcal
Last active November 10, 2025 14:54
Show Gist options
  • Select an option

  • Save msmarcal/ff4f17fb72dd5cd898c3c1ad4b1091a6 to your computer and use it in GitHub Desktop.

Select an option

Save msmarcal/ff4f17fb72dd5cd898c3c1ad4b1091a6 to your computer and use it in GitHub Desktop.
How to upgrade MAAS postgresql from 14 to 16

Upgrade MAAS postgresql from 14 to 16

MAAS 3.6, which supports PostgreSQL 16, requires Ubuntu 24.04 LTS. Upgrade your system to this release before proceeding with the PostgreSQL upgrade.

You should upgrade the node Ubuntu distribution to 24.04 LTS before attempting to upgrade MAAS, so plan your maintenance window appropriately. Note that you might be required to upgrade PostgreSQL to version 16 before continuing with the MAAS upgrade.

Backup Your Database

Always back up your PostgreSQL data before performing a major upgrade.

sudo -u postgres pg_dumpall > backup.sql

Upgrade Ubuntu to 24.04 LTS (Noble)

Fully update your current system:

sudo apt update
sudo apt upgrade

Check for sufficient free disk space

df -h

Backup all important data and configurations - this is critical in case something goes wrong.

Reboot if needed - check if /run/reboot-required exists, which indicates a reboot is necessary.

Use the do-release-upgrade command:

sudo do-release-upgrade

Important Notes

  • It is significantly safer to upgrade a remote system using a hardware-based KVM over IP solution
  • The upgrade is interactive - you'll need to monitor the process and respond to prompts about configuration file changes and package removals.
  • Third-party repositories and PPAs will be automatically disabled during the upgrade. You'll need to re-enable them afterward if needed.
  • Reboot is required - the system must be rebooted after the upgrade completes for changes to take effect.

Install PostgreSQL 16

On Ubuntu 24.04, install PostgreSQL 16 using:

sudo apt update
sudo apt install postgresql-16

Stop MAAS Services

Stop MAAS to prevent database writes during the upgrade:

sudo snap stop maas          # for snap installs

Upgrade the PostgreSQL Cluster

Use the pg_upgradecluster tool to upgrade your cluster from 14 to 16.

Drop the newly created 16 cluster:

sudo pg_dropcluster 16 main --stop

Upgrade de older cluster to the new version

sudo pg_upgradecluster 14 main

This will migrate your data to the new PostgreSQL 16 cluster.

Reconfigure MAAS to Use PostgreSQL 16 (if needed)

Ensure MAAS is configured to use the new PostgreSQL 16 cluster, which should be on the default port (5432).

Start MAAS Services

Restart MAAS:

sudo snap start maas          # for snap installs

Remove Old PostgreSQL 14 Cluster and Packages

Once you have verified that everything is working, remove the old cluster and packages:

sudo pg_dropcluster 14 main

sudo apt remove postgresql-14 postgresql-client-14 -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment