Updating from PostgreSQL 9.6 or 9.4 to PostgreSQL 11

This article only applies to UCS 5.0.

UCS 5.0 ships PostgreSQL 11 by default, while UCS 4.3 shipped PostgreSQL 9.6 by default and UCS 4.2 shipped with PostgreSQL 9.4. When UCS 4.4 systems are updated, however, the installed PostgreSQL version is retained.

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

[ -f /usr/sbin/univention-pkgdb-scan ] &&
  chmod -x /usr/sbin/univention-pkgdb-scan
service postgresql stop
rm -rf /etc/postgresql/11
ucr set postgres11/autostart='yes'
apt-get install --reinstall postgresql-11
pg_dropcluster 11 main --stop
service postgresql start
[ -e /var/lib/postgresql/11/main ] &&
  mv /var/lib/postgresql/11/main /var/lib/postgresql/11/main.old
if pg_lsclusters -h | grep -q '^9\.6 '; then 
  pg_upgradecluster 9.6 main
elif pg_lsclusters -h | grep -q '^9\.4 '; then 
  pg_upgradecluster 9.4 main
fi
ucr commit /etc/postgresql/11/main/
chown -R postgres:postgres /var/lib/postgresql/11
service postgresql restart
[ -f /usr/sbin/univention-pkgdb-scan ] &&
  chmod +x /usr/sbin/univention-pkgdb-scan
univention-install --yes univention-postgresql-11

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

if pg_lsclusters -h | grep -q '^9\.6 '; then 
  pg_dropcluster 9.6 main --stop
  service postgresql restart
  apt-get purge postgresql-9.6
elif pg_lsclusters -h | grep -q '^9\.4 '; then 
  pg_dropcluster 9.4 main --stop
  service postgresql restart
  apt-get purge postgresql-9.4
fi