Updating from PostgreSQL 9.4 to PostgreSQL 9.6

This article only applies to UCS 4.3.

UCS 4.3 ships PostgreSQL 9.6 by default, while UCS 4.2 shipped PostgreSQL 9.4 by default. When such systems are updated, however, the installed PostgreSQL version is retained.

The following steps are necessary on a UCS-4.3 system for updating PostgreSQL 9.4 to PostgreSQL 9.6

[ -f /usr/sbin/univention-pkgdb-scan ] && chmod -x /usr/sbin/univention-pkgdb-scan
service postgresql stop
rm -rf /etc/postgresql/9.6
apt-get install --reinstall postgresql-9.6
pg_dropcluster 9.6 main --stop
service postgresql start
test -e /var/lib/postgresql/9.6/main && mv /var/lib/postgresql/9.6/main /var/lib/postgresql/9.6/main.old
pg_upgradecluster 9.4 main
ucr commit /etc/postgresql/9.6/main/*
chown -R postgres:postgres /var/lib/postgresql/9.6
service postgresql restart
[ -f /usr/sbin/univention-pkgdb-scan ] && chmod +x /usr/sbin/univention-pkgdb-scan
univention-install --yes univention-postgresql-9.6

Once the new database / data inventory has been verified, the PostgreSQL 9.4 data can be removed / the software package uninstalled:

pg_dropcluster 9.4 main --stop
service postgresql restart
apt-get purge postgresql-9.4