Sample Header Ad - 728x90

Using docker containers to execute pg_upgrade

1 vote
1 answer
334 views
using pg_upgrade when you have installed both the 'old' version and the 'new' version on a system is quite straightforward. I tried to find a way using pg_upgrade with docker containers. This is a little bit more complicated because you need the 'old datadir', the 'old bindir' and the 'new datadir'and the 'new bindir' of the 'old' and the 'new' postgres version you want to upgrade from and upgrade to. Because the 'old directories' are not present in the 'new' version docker container you have to mount them into the 'new' container. But since pg_upgrade seems to expect not only the 'old' bindir and datadir but also the 'old' libraries (postgres depends on) of the older version, you also have to mount them into the new versions' container. So I ended up running an 'old-version-container', copying the bindir, datadir and lib dir to the local docker host and mounting them in the 'new-version-container' when coming from postgres-12 this means copying the contents of /usr/lib/ to the local docker host and remounting them to the 'new-version-container' so I mounted the 'old-libdir' to /12-bindir/ and did ldd /12-bindir/postgres to find out which libs postgres depends on. After copying the 'old-libs' to /usr/lib in the 'new-version-container' all dependencies could be found and I was able to use pg_upgrade and actually upgrade a database from (i.e. postgres-12-alpine to postgres:15.10-bookworm) so.. it worked.. So.. the real question is: because it works.. should I do it like this or do I miss something and am I doing something stupid or silly? I am glad about every hint and opinion
Asked by D M (445 rep)
Jan 20, 2025, 11:44 AM
Last activity: Jan 21, 2025, 08:11 AM