Upgrade Ubuntu 16.04 postgres from 9 to 12
Linux Postgres Database Ubuntu
Add the repo:
sudo echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list
Import the key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Update:
sudo apt update
Install:
sudo apt install postgresql-12 postgresql-client-12 postgresql-contrib-12
Stop:
sudo pg_dropcluster 12 main --stop
Migrate:
sudo pg_upgradecluster 9.5 main
Remove:
sudo pg_dropcluster 9.5 main
Check:
sudo systemctl status postgresql
Double check:
pg_dump -V
From: https://gist.github.com/Clark-G/01fcb84c658c44dcec4af1a965e2c3b4