0

I am trying to upgrade PostgreSQL version from 9.6 to 11. I am following this link. The problem is I have changed my default location of PostgreSQL data directory from /var/lib/postgresql/ to /opt/postgresql/. So when I am using pg_lsclusters it is returning following

enter image description here

When I am running the sudo pg_upgradecluster -m upgrade 9.6 main its returning following error

Error: move_conffile: required configuration file /var/lib/postgresql/11/main/postgresql.conf does not exist
Error: Could not create target cluster
2

You can specify a custom data_directory as an optional parameter to the command pg_upgradecluster:

pg_upgradecluster [-v newversion] oldversion name [newdatadir]

So for your case, it should be:

sudo pg_upgradecluster -m upgrade 9.6 main /opt/postgresql/11/main

Note that you must first remove any existing cluster at the specified location (/opt/postgresql/11/main) and create an empty directory with the correct owner before running pg_upgradecluster:

sudo pg_dropcluster --stop 11 main
sudo mkdir -p /opt/postgresql/11/main
sudo chown postgres:postgres /opt/postgresql/11/main
  • Does this work? as I have custom data directory for the 9.6 version also – Devil's Dream Oct 1 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.