Upgrading Postgresql from version 9.4 to 9.6

Posted on 28-06-2018 by Nadir Latif

Source: https://scottlinux.com/2015/11/14/upgrade-postgresql-on-debian-jessie-with-pg_upgradecluster/

Debian Stretch does not support Postgresql version 9.4 which is provided by Debian Jessie. To upgrade Postgresql from 9.4 to 9.6, I followed the instructions given on: Upgrade postgresql on Debian Jessie with pg_upgradecluster. Although the instructions are for upgrading from version 9.1 to 9.4, they work for upgrading from 9.4 to 9.6. To upgrade from 9.4 to 9.6, we need to first install Postgresql 9.6 using the command: sudo apt-get install postgresql-9.6

Next we need to drop the main cluster created during installation of 9.6. We can do this with the command: sudo pg_dropcluster --stop 9.6 main

Next we need to stop the postgresql-9.4 with the command: service postgresql stop. After that we need to upgrade the cluster from version 9.4 to 9.6 using the command: pg_upgradecluster -v 9.6 9.4 main. After that we can remove the postgresql-9.4 with the command: apt-get remove postgresql-9.4