OLD_VERSION=9.6
NEW_VERSION=11
# make sure the new cluster doesn't exist
pg_dropcluster --stop $NEW_VERSION main
# upgrade to a newer cluster
pg_upgradecluster -v $NEW_VERSION $OLD_VERSION main
# edit the new cluster configuration (you should at least change the port to reuse the old one)
pg_ctlcluster $NEW_VERSION main stop
vi /etc/postgresql/$NEW_VERSION/main/postgresql.conf
pg_ctlcluster $NEW_VERSION main start
# CHECK EVERYTHING IS OK
# now you can drop the old cluster
pg_dropcluster $OLD_VERSION main
# optionally you can remove the old packages
apt purge postgresql-$OLD_VERSION postgresql-client-$OLD_VERSION postgresql-contrib-$OLD_VERSION