Reputation: 715
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
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
Upvotes: 0
Views: 4134
Reputation: 21697
It sounds like you moved the folder before running pg_upgradecluster
so now it can no longer find the config file.
If you already have a backup, I would do the following:
/opt/postgresql/9.6/main
back to where it was before (in /var/lib/postgresql
)/opt/postgresql/11/main
pg_upgradecluster 9.6 main /opt/postgresql/11
This will tell it to use the default location of 9.6/main
and store the upgraded version into /opt/postgresql/11
I am unsure about the second point as I don't remember how pg_upgradecluster
deals with existing folders. But as long as you keep a backup, you can play around with it. My best guess is that it will exit with an error if it sees that the folder already exists to ensure nothing is overwritten. So you may need to delete it.
You could try to move the folder back to the old location and then run pg_upgradecluster
again. But you have to be careful: The version 9.6 to 11 is a major upgrade which changes the on-disk binary format. pg_upgradecluster
should take care of this by making a dump/load operation.
Here are some pointers to get you going:
pg_upgradecluster
does nothing more than a dump/load but with a more convenient CLI interfacepostgres -D </path/to/postgres/9.6/main> -c </path/to/9.6/main/postgresql.conf> -p <port>
pg_dumpall --cluster 9.6/main -Ft -f dump.tar
pg_createcluster -d /opt/postgresql --start 11 main
(using --start
will start it up after creation).pg_restore --cluster 11/main -Ft -f dump.tar
for your dump/load needsUpvotes: 1