Backup your DBs
sudo -u postgres pg_dumpall > backup.sql
apt install postgresql-14 postgresql-server-dev-14
Stop PSQL.
systemctl stop postgresql.service
cd to /tmp/
to allow the upgrade script to create any files it needs
cd /tmp/
sudo -u postgres /usr/lib/postgresql/14/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/12/main \
--new-datadir=/var/lib/postgresql/14/main \
--old-bindir=/usr/lib/postgresql/12/bin \
--new-bindir=/usr/lib/postgresql/14/bin \
--old-options '-c config_file=/etc/postgresql/12/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/14/main/postgresql.conf'
Change PSQL v14's config to use port 5432
vim /etc/postgresql/14/main/postgresql.conf
Change PSQL v12's config to use port 5433
vim /etc/postgresql/12/main/postgresql.conf
Start PSQL
systemctl start postgresql.service
Check the new version
sudo -u postgres psql -c "SELECT version();"
Run the vacuumdb
utility
sudo -u postgres /usr/lib/postgresql/14/bin/vacuumdb --all --analyze-in-stages
All DB user password MUST be reset. Login as postgres
sudo -u postgres psql
Change all user passwords
\password user1
Remove the old PSQL version
apt remove postgresql-12*
apt autoremove
Run the delete cluster script
sudo -u postgres ./delete_old_cluster.sh
Remove v12 files
rm -rf /etc/postgresql/12/