How to pg_upgrade with an User-defined Data-Directory

951 Views Asked by At

Running PostgreSQL on MANJARO, the actual /var/lib/postgres/data/postgresql.conf defines my Data-Directory:

data_directory = '/mnt/Data/.../PostgreSQL'

Now I'm facing the upgrade from PostgreSQL 13 to 14 and I'm thinking to use pg_upgrade, as described in the Arch-Wiki. The Step 4.) described there is pretty clear, but is it also sufficient for my data_directory = '/mnt/Data/.../PostgreSQL' or do I need to take additional actions? Furthermore, I'm thinking to have versioned directories, e.g.

/var/lib/postgres/data/14/
/mnt/Data/.../PostgreSQL/14/

What should I consider to realize that? Thank you!

1

There are 1 best solutions below

2
On

When running pg_upgrade, point the --old-datadir and --new-datadir options to the directories that contain postgresql.conf (not to the actual data directories). I admit that this is confusing; however, the documentation says:

-d configdir
--old-datadir=configdir

the old database cluster configuration directory; environment variable PGDATAOLD

Note that the wording is “cluster configuration directory”, not “data directory”.