PostgreSQL upgrade
For development setups and most of production ones too, the PostgreSQL database run through Docker and its data is stored through a Docker volume.
To avoid any data loss, we strongly advice to save a copy of the volume before continuing with the following instructions. By default the volume is located at /var/lib/docker/volumes/callico_database/ and requires a privileged access (root).
Upgrade PostgreSQL data from version 13 to 17
We recommend performing the update using pg_dump, as it simplifies handling multiple major PostgreSQL updates.
-
Make sure you ran all the latest migrations and checked out to the new version in
docker-compose.yml -
Back up the existing data using
pg_dump:docker run --rm --name=old-database --env-file=docker.env -v callico_database:/var/lib/postgresql/data -p 127.0.0.1:5432:5432 postgres:13-alpine docker exec old-database pg_dump -U callico -d callico > dump.sqlThere should be no error and the size of
dump.sqlshould be approximately the size of the volume. -
Trash the previously used volume:
docker kill old-database docker volume rm callico_databaseYou will need to kill all database access first (e.g. Ctrl-C in the DB shell). In case docker complains about a container using the volume, you may also have to delete the container first:
docker rm <container_id> -
You can then run the up-to-date PostgreSQL via
docker-compose.yml, and restore the data:docker exec callico-database postgres -V # Should return "postgres (PostgreSQL) 17.x" docker compose up postgres PGPASSWORD=callicopwd psql --user=callico --host=localhost -d callico < dump.sql -
Check the application runs as expected by starting a development server and running tests (all your data should be there).
-
Cleanup the local file used for the dump:
rm dump.sql