Install to be able to sign custom repository
apt install gnupg gnupg2
Add custom repository to apt list
nano /etc/apt/sources.list.d/pgdg.list
In Nano add this line and save
deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main
Sign added repository
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Signing needs to return
OK
Update repositories
apt update
Install new PostgreSQL version
apt install postgresql-12
If database has connections outside localhost (for you to be able to connect with desktop client)
cd /etc/postgresql/12/main/
nano postgresql.conf
In nano find (CTRL + W) listen_addresses, remove comment symbol (#) and CHANGE localhost with *
listen_addresses = '*'
To setup hosts that can access database open confiruration file
nano pg_hba.conf
In Nano add hosts that need to connect to database
host all all 10.63.0.0/16 md5
Check if postgresql is active listening on configured port (default 5432)
lsof -i -P -n | grep LISTEN
Drop default empty cluster created with new version instalation
pg_dropcluster 12 main
Stop old version cluster before upgrade
pg_ctlcluster 11 main stop
Upgrade old version cluster to new version (in this case 11->12)
pg_upgradecluster -v 12 11 main -m upgrade
Start upgraded cluster
pg_ctlcluster 12 main start
Reload deamon to use new version on server restart
systemctl daemon-reload