- Create a backup
$ pg_dumpall > <backup_output_file>
- Install Postgres 11
Create a
pgdg.list
$ sudo vi /etc/apt/sources.list.d/pgdg.list
Add the repo based on version
deb http://apt.postgresql.org/pub/repos/apt/ YOUR_UBUNTU_VERSION_HERE-pgdg main
Then install
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-11
Run pg_lsclusters
$ pg_lsclusters
Upon running of pg_lsclusters
there will be a cluster main
for postgres 11
Stop the 11 cluster
$ sudo pg_dropcluster 11 main --stop
Make sure to stop all processes and services
$ sudo systemctl stop postgresql
Upgrade the 9.5 cluster
$ sudo pg_upgradecluster -m upgrade 9.5 main
Start postgresql
$ sudo systemctl start postgresql
Check data before removing the old version. If it's all good, then do a
$ sudo pg_dropcluster 9.5 main --stop
Reference: