windowspostgresqlpostgresql-12pg-upgrade

Error using pg_upgrade going from PostgreSQL 10 to 12


I have an installation of PostgreSQL 10, and just installed PostgreSQL 12 (on Windows). I'm trying to migrate over the databases using pg_upgrade. However, I'm getting an annoying error:

The command I ran was as follows:

$ pg_upgrade.exe -b 'C:\Program Files\PostgreSQL\10\bin\' -B 'C:\Program Files\PostgreSQL\12\bin\
' -d 'C:\Program Files\PostgreSQL\10\data\' -D 'C:\Program Files\PostgreSQL\12\data\'

However, I get the error message:

You must identify the directory where the new cluster binaries reside.
Please use the -B command-line option or the PGBINNEW environment variable.
Failure, exiting

... despite clearly doing so.

Anyone seen this before?


Solution

  • From the "For Windows users .." users section in step "9) Run pg_upgrade" at this page:

    For Windows users, you must be logged into an administrative account, and then start a shell as the postgres user and set the proper path:

    RUNAS /USER:postgres "CMD.EXE"
    SET PATH=%PATH%;C:\Program Files\PostgreSQL\12\bin;
    

    and then run pg_upgrade with quoted directories, e.g.:

    pg_upgrade.exe
       --old-datadir "C:/Program Files/PostgreSQL/9.6/data"
       --new-datadir "C:/Program Files/PostgreSQL/12/data"
       --old-bindir "C:/Program Files/PostgreSQL/9.6/bin"
       --new-bindir "C:/Program Files/PostgreSQL/12/bin"