Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading from 14 to 15 failing with "/var/lib/postgresql/14/data/PG_VERSION": No such file or directory #68

Open
TommyTran732 opened this issue Nov 18, 2022 · 6 comments

Comments

@TommyTran732
Copy link

This is a reoccurrence of #36

I am using the alpine postgres image if that matters

@TommyTran732 TommyTran732 changed the title Upgrading from 14 to 15 failing with "/var/lib/postgresql/14/data/PG_VERSION": No such file or directory Upgrading from 14 to 15 failing with "/var/lib/postgresql/14/data/PG_VERSION": No such file or directory Nov 18, 2022
@casalegno
Copy link

I have the same problem. Have any solution?

@casalegno
Copy link

Reading and rereading the documentation I got an Idea: is not possible upgrade. This tool is for pg_upgrade that is not intended for major upgrade

@squatica
Copy link

@casalegno the first paragraph of pg_upgrade manual contradicts your statement:

https://www.postgresql.org/docs/9.5/pgupgrade.html

pg_upgrade (formerly called pg_migrator) allows data stored in PostgreSQL data files to be upgraded to a later PostgreSQL major version without the data dump/reload typically required for major version upgrades, e.g., from 8.4.7 to the current major release of PostgreSQL. It is not required for minor version upgrades, e.g., from 9.0.1 to 9.0.4.

@manuelminca
Copy link

Same problem here. The error makes sense since I don't have installed PG locally. I followed the documentation to use the volume to point to my data directory which contains PG_VERSION. But the docker container doesnt seem to use it.

I might try to install locally Postgres so it can find the file and the binary files.

@TommyTran732 TommyTran732 changed the title Upgrading from 14 to 15 failing with "/var/lib/postgresql/14/data/PG_VERSION": No such file or directory Upgrading from 14 to 15 failing with "/var/lib/postgresql/14/data/PG_VERSION": No such file or directory Dec 1, 2023
@manuelminca
Copy link

manuelminca commented Dec 1, 2023

Alright I found the way to solve it.

To give more context. My old data directory is mounted in a external disk in "/mnt/data/postgres" and I want to move the files to /mnt/data/postgres/16/postgres.

docker run --rm \
-v /mnt/data/postgres:/var/lib/postgresql/data \
-v /mnt/data/postgres/16/postgres:/var/lib/postgresql/16/data \
-e PGDATAOLD=/var/lib/postgresql/data \
-e PGDATANEW=/var/lib/postgresql/16/data \
tianon/postgres-upgrade:12-to-16 

The -v connects my local filesystem with the internal one in the docker container. And then, since PGDATAOLD and PGDATANEW env variables will be used inside the docker container, should point to the inner docker path.

That way works without setting --link option. With the --link option it complains about:

"could not create hard link between old and new data directories: Invalid cross-device link
In link mode the old and new data directories must be on the same file system."

Update:
The error makes sense since we are mounting 2 separate volumes. To use --link option, we have to only mount 1 volume and then reference properly in the ENV variables:

docker run --rm \
  -v /mnt/data/:/var/lib/postgresql/ \
  -e PGDATAOLD=/var/lib/postgresql/postgres \
  -e PGDATANEW=/var/lib/postgresql/postgres/16 \
  tianon/postgres-upgrade:12-to-16 --link

And it works as expected 😄

@empereira
Copy link

@manuelminca

Both containers need to be running, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants