Introduction
I was using Ubuntu 14.04 LTS and wanted to update the system to a newer version, Ubuntu 16.04 LTS. The upgrade process worked fine, but Ubuntu 16.04 LTS came also packaged with a new PostgreSQL version, however – for good reasons – it does not upgrade your databases automatically. So after the update there were two instances of PostgreSQL (9.4 and 9.5) and I was greeted with the following notification:
The PostgreSQL version 9.4 is obsolete, but the server or client packages are still installed. Please install the latest packages (postgresql-9.5 and postgresql-client-9.5) and upgrade the existing clusters with pg_upgradecluster
Eeehhhh yeah, right, but how do you upgrade it exactly to the next version?
The upgrade process
The upgrade process is the same for the last few versions:
- Stop the new version
- Run the upgrade from the old version/cluster
- Remove the old cluster
- (You could deinstall the packages for the old version)
Upgrade from PostgreSQL 9.3 to 9.4
sudo pg_dropcluster 9.4 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
Upgrade from PostgreSQL 9.4 to 9.5
sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.4 main
sudo pg_dropcluster 9.4 main