-1

The question specifically focuses on the assumed required upgrade of the data structures when stepping up to the next or even latest major release.

I know it usually involves dumping the data before the update and then replaying it afterwards, but maybe there are other tricks or procedures as well?

If the solution is a one-liner or a compact shell script does not really matter.

It would be great if it works for both upgrading to the next, a specific or the latest release.

Assumptions:

  • let's assume we are on an up-to-date Ubuntu 22.04 system
  • the postgresql 10.x container is part of some service that was brought up via docker-compose
  • the official images from https://hub.docker.com/_/postgres are used
  • we are in the folder ($PWD) of the corresponding docker-compose.yaml file
  • the postgresql container and data is currently on revision 10.x
  • the data are stored on a mapped volume (alternatively a named volume if that matters)
  • finally the upgrade should go to either the following major release (such as 11) or to the latest stable (15).

Actually this asks if the upgrade must take multiple iterations or if it can be done jumping over many major releases in one cycle.

Edit: although I asked a very similar question targeting mariadb I found it useful and straight forward asking it for postgresql as well because different solutions may apply.

0

2 Answers 2

1

You could give this dockerized environment generator for pg_upgrade a try. It is basically a flexible version of what Laurenz Albe suggests in his answer.

Disclaimer: I am the creator of that project.

1
  • Not a 1-liner, but that worked well for me a few times already.
    – datenheim
    Jun 4, 2023 at 9:50
1

That's one of the downsides of using a container: upgrade is more complicated. Well, actually most administrative tasks are.

You could create a special "upgrade" container with both PostgreSQL versions in it, mount your data volumes in that and run pg_upgrade.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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