docker-pgautoupgrade: initdb: error "/var/lib/postgresql/data" exists but is not empty
I’m trying to upgrade from postgres 14 to 15 while retaining data.
When I use the image to pgautoupgrade/pgautoupgrade:latest instead of postgres:14 in the compose file and restart, I get the following errors.
initdb: error: directory "/var/lib/postgresql/data" exists but is not empty
If you want to create a new database system, either remove or empty
he directory "/var/lib/postgresql/data" or run initdb
with an argument other than "/var/lib/postgresql/data".
Maybe I’m misunderstanding but shouldn’t the data directory be not empty? It should, and does, have data from version 14 that I want migrated to 15. Thank you for any help.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 61 (56 by maintainers)
okay, now realizing that isn’t actually a standalone reproduction, requires the volume having something in it first. standby…
okay, in additinon to the above facepalm, i also realized i wasn’t deploying my patched version of your code but was building main.
now i’m back on track possibly getting better info. i got a build with all this glorious log output. then i put i more logging and for some reason the next run didn’t have any output. still trying to figure out if my fault or something else, but want to safe this here for posterity. the interesting things are
mv: can't rename '/var/lib/postgresql/data/pgdata/old': Invalid argument- i put in some logging here to try to figure out what it’s trying to move, but that didn’t work… yeti knew i was flying too close to the sun thinking i could use
falsein shell scripting. my text editor highlights it a different color! why!i think it made it past this
and then it died after this
right but the makefile doesn’t support building
PGTARGET=12(upgrading to 12)but changing up the invocation was trivial, so i think we are off to the races
seems to be building just fine (will be half an hour because building AMD on my ARM mac)
my existing version: 12 🫠
wow, thanks for the offer - although i fear the turnaround time on each experiment will be too long, so maybe we should get me a working shell first. you can find my email off of my website linked here https://github.com/jjb
Yep, for testing purposes, just to see if the script runs ok with it gone. 😄
okay, just nuke the whole
volumessection?sounds good, thanks! but i think maybe you missed the error message i got when i tried my hack - see the text under the image here https://github.com/pgautoupgrade/docker-pgautoupgrade/issues/7#issuecomment-2000638399
Ahhhh. Oh, now that all makes sense.
Ahhh, I have an idea. Gimme a minute to write it… 😄
never mind, i see the entrypoint needs to run… will figure out a better way to NOOP it
will work on that
I tested with
devtag, it works now!No worries at all. Thanks for trying it out, and providing feedback, which is how projects improve over time. 😄