Upgrade Postgres version (Docker-Compose)

Here you will learn how to upgrade the postgres database version of your existing open-appsec deployment on docker (relevant for docker-compose-based deployment).

When is a postgres database upgrade required?

This is ONLY relevant if ALL of the following applies to your current deployment:

  • redeployment/ugprade of an existing open-appsec deployment (this is not relevant for new deployments)

  • current deployment is a standalone deployment (without a web UI profile token provided in the .env file, when connecting to web UI with a profile token typically there should not be any local postgres database being deployed/used)

  • current deployment has the docker-compose standalone profile set in the .env file (otherwise postgres container wouldn't be deployed/used at all)

  • current postgres version shall be replaced with newer postgres image version, which is also a new major release (which means database conversion is required)

Postgres database upgrade instructions

Before upgrading from an existing to a newer major release postgres database version (using newer postgres container version tag) in your existing open-appsec deployment on Docker, the existing database files must be converted properly for compatibility with the new version.

If you already switched and ran a newer postgres container image with new postgres major version, follow the instructions further below to run a script to fixing your postgres database structure so it will work with the new postgres version: Upgrade Postgres version (Docker-Compose)

  • If you are not using the latest docker-compose files yet: Download the latest docker-compose.yaml file and .env file and apply your desired configuration changes (see also Deploy With Docker-Compose)

  • In the .env file set the value for APPSEC_POSTGRES_VERSION as required to a new major release postgres version. This setting will be used for the database upgrade using the script below and also as the tag for the new postgres container to be deployed (postgres database downgrades are not supported!)

  • Now run the migrate-postgres.sh script following these steps before deploying the updated environment with docker-compose:

wget https://downloads.openappsec.io/scripts/migrate_postgres.sh
chmod +x ./migrate_postgres.sh
./migrate_postgres.sh

This script will automatically migrate the existing postgres database to the database format of the new postgres version specified in the .env file in with this configuration key: APPSEC_POSTGRES_VERSION.

  • Now you can restart your existing docker-compose-based deployment including pulling the new container images

    docker-compose down
    docker-compose pull
    docker-compose up -d

You now have an open-appsec deployment with an upgraded postgres database version up and running.

Recover postgres structure if postgres version was upgraded without running migrate_postgres.sh tool first

If you already switched and ran a newer postgres container image with new postgres major version, follow the instructions further below to fix your postgres database structure retroactively so it will work correctly with the new postgres version.

Perform these steps to download and run a script which recovers your postgres structure to make it work correctly with your new postgres major version.

wget https://downloads.openappsec.io/scripts/recover_postgres_structure.sh
chmod +x ./recover_postgres_structure.sh
./recover_postgres_structure.sh 

Last updated

Was this helpful?