Upgrade from PostgreSQL 15 to 17 on Windows using pg_upgrade
Overview
At work I needed to upgrade from PostgreSQL from 15 to 17. The process is not that different than upgrading in Ubuntu but there were a couple of items that threw me off.
Perform Backup
This should be done prior to the update in case something goes wrong:
| |
This was based on the documentation PostgreSQL: Documentation: 17: pg_dumpall.
Note keep in mind that you should create a pgpass.conf
(or .pgpass for Linux):
| |
This file is located C:\Users\ctyler\AppData\Roaming\postgresql
(or chmod 0600 ~/.pgpass with the right permissions).
PostgreSQL: Documentation: The Password File.
Remove admipack extension
This extension will need to be removed as it have been deprecated:
| |
Stop Both Servers
Go to Start->Search->Serivces and stop both services:

Update pg_hba.conf
Make the following changes:
| |
This remove the permissions so that you don’t error during upgrade. This need to be done on both clusters.
Run pg_upgrade
Now let’s perform the upgrade. Open PowerShell as Adminstrator.
| |
I had to add ports and postgres user.
I got this info from
Upgrading PostgreSQL in Windows · GitHub
Once complete you should get:
| |
Next Steps
After you verify that PostgreSQL 17 works as intended, you can then remove 15.
I would suggest having a backup strategy.
For example on Ubuntu, I use ZFS to create snapshots and push those snapshots to
a backup server and an external hard disk.
On Windows, I have a simple PowerShell script that will use pg_dump and
pg_dumpall.
pg_dump is for the tables that I need to backup monthly.
Most of the data in my databases come from other data sources and don’t really
need to be backed up.
The total downtime was only a couple of hours and I shouldn’t have a reason not to upgrade PostgreSQL yearly.