Skip to content

Upgrade Docker images

Thomas Piller edited this page Sep 22, 2023 · 7 revisions

PostgreSQL with PostGIS extension

Upgrade instructions

⚠ Commands below expect a MapX stack running with docker compose.

  1. Shutdown services

    # Stop all services to avoid write on pg
    docker compose down
    
    # Optionally, set 'maintenance mode' on app ( env file ) and restart it
    # docker compose up -d app
  2. Export dump

    # Start pg service and wait for the service to be listening ~ 1 min
    docker compose up -d pg
    
    # Dump PostgreSQL entire cluster ( -c = clean db instruction, used at re-import time ) 
    docker compose exec pg pg_dumpall -U postgres -c | gzip > {filename}.gz
    
    # Alternative with uncompressed output
    # docker compose exec pg pg_dumpall -U postgres -c  > {filename}.sql
    
    # Shut down pg
    docker compose stop pg
  3. Move the postgres data folder

    The postgres data folder must be empty when the volume is imported in the new container. That folder could be moved or simply removed.

    # Move / backup the postgres data folder.
    
    # Using volume and a base image. Shared volume name depend on your config: `docker volume list`.
    docker run --rm -v {your shared volume name}:/shared alpine:3.12 mv /shared/postgres /shared/postgres_orig
    
    # Alternatively, using a folder. With a shared folder named "_shared", just do :
    # mv _shared/postgres _shared/postgres_orig
  4. Update Docker image in the file docker-compose.yml

    ...
      pg: image: postgis/postgis:14-3.1-alpine
    ...
  5. Restart pg service and re-import dump

    # Instantiate pg & wait for the db to be ready ~1 min
    docker compose up -d pg
    
    # Import archive file (-T = no TTY)
    gunzip < {filename}.gz | docker compose exec -T pg psql -U postgres -d mapx
    
    # Import uncompressed sql file 
    # cat {filename}.sql | docker compose exec -T pg psql -U postgres -d mapx
  6. Restart all services

    docker compose up

Known Issues / Errors

When You encounter errors due to PostGIS upgrade:

ERROR: could not get commit timestamp data
HINT: Make sure the configuration parameter "track_commit_timestamp" is set.

Run:

docker compose exec pg psql -U postgres
> ALTER SYSTEM SET track_commit_timestamp = 'on';
> \q
docker compose restart
Clone this wiki locally