Postgresql – Upgrade postgres without messing with ports

postgresqlupgrade

The standard procedure for upgrading Postgres appears to require that I temporarily run both the old and the new version. This means that I have to change the port of the old version.

This seems completely unnecessary, given how I’m telling pg_upgrade exactly where to find the data directories and it could just go and read all the data directly.

Is this really the only way to upgrade (apart from dump/restore), or am I misunderstanding something? Can I not just ask the upgrader to convert all the binary data files directly, without messing with users, passwords and ports?

Best Answer

Given step 9 in the link you provided:

9.Run pg_upgrade ... Obviously, no one should be accessing the clusters during the upgrade. pg_upgrade defaults to running servers on port 50432 (sic) to avoid unintended client connections. You can use the same port numbers for both clusters because the old and new clusters will not be running at the same time. ...

It looks like it is just an available option.