When doing a major version upgrade on Debian Linux with PostgreSQL server installed (using Debian-provided packages), this always catches me: After the upgrade there will be two different PostgreSQL instances running, it won’t do an in-place upgrade for the database automatically.
In order to get the existing database running on the newer PostgreSQL version, this is what I need to do:
- Backup the database (this is important if something goes wrong!)
- Upgrade the system normally (here I’ll use Debian 11 (Bullseye) to 12 (Bookworm) upgrade as en example)
- See that both
postgresql@13-main.serviceandpostgresql@15-main.serviceare running (both TCP ports 5432 and 5433 are shown listening withss -ntlcommand)- PostgreSQL 13 is from Debian 11, PostgreSQL 15 is from Debian 12
- Run
sudo pg_dropcluster --stop 15 main - Run
sudo pg_upgradecluster 13 main - Check that everything works fine
- Check
dpkg -l postgresql\*for any old version packages installed, then delete them withapt purge
Your mileage may vary, and all other usual caveats apply.