Shut down MAAS before starting this upgrade
Errors or typos? Topics missing? Hard to read? Let us know!
Optional but strongly advised: backup all existing data.
sudo -u postgres pg_dumpall > backup.sql
Update and install packages
bash
sudo apt-get update
sudo apt-get install postgresql-14 postgresql-server-dev-14
Halt the old server
bash
sudo systemctl stop postgresql.service
Migrate configuration files
bash
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'
Reconfigure server ports
bash
sudo vim /etc/postgresql/14/main/postgresql.conf # Set port to 5432
sudo vim /etc/postgresql/12/main/postgresql.conf # Set port to 5433
Activate new server and verify version
bash
sudo systemctl start postgresql.service
sudo -u postgres psql -c "SELECT version();"
Execute new cluster script
bash
sudo -u postgres ./analyze_new_cluster.sh
PostgreSQL v14 defaults to scram-sha-256
for password hashing. Redefine all existing passwords.
sudo -u postgres psql
postgres=# \password $USER
Or, modify /etc/postgresql/14/main/pg_hba.conf
to switch back to md5
. But be cautious, as future versions may not support MD5.
Remove old packages
bash
sudo apt-get remove postgresql-12 postgresql-server-dev-12
Delete configuration and data
bash
sudo rm -rf /etc/postgresql/12/
sudo -u postgres ./delete_old_cluster.sh