3.10. Database Migrations
Although we try our best to automatically migrate your server when upgrading versions, there are times when this is simply not possible. In this section we will attempt to cover some of the most common migrations you might encounter when running our software yourself via a Docker container.
Do not attempt to upgrade beyond more than two major GeoPrism Registry versions at a time.
The general steps for performing any sort of migration can be broken down as follows:
Create a clone environment of your production server where we will test these steps
Perform all required steps as outlined in the "Orient DB Migration" and/or "PostgreSQL Migration" sections below on the cloned environment, keeping track of the exact commands relevant for your environment and making note of any issues or cavaets.
Set your docker-compose.yml file (in the test environment) to the new GeoPrism Registry / Postgres / OrientDB versions and run
docker compose down
thendocker compose pull
. Then do adocker compose up
. When the GeoPrism Registry boots, it will automatically run any additional patches or migration scripts as necessary. Be patient as this step can take time.Check the logs for any errors and make sure the test server is operational and responding.
Allocate a "downtime window" for your server so as to disturb users as little as possible
Perform a snapshot / backup of your production server
Stop the webserver with
docker stop georegistry
Perform the steps exactly as they were performed on the test environment, except this time on the live production environment
Orient DB Migration
If a newer version of the GeoPrism Registry requires a major upgrade of your Orient DB software, a manual data migration must be performed.
The official OrientDB migration documentation can be found here:
http://www.orientdb.com/docs/last/release/Upgrade.html
Since the official OrientDB migration documentation can be either confusing, lacking in detail, or simply not targeted towards the way we use their software, we will walk you through the detailed steps here.
Stop the webserver with
docker stop georegistry
Create a database dump of the Orient DB server. This command includes variables (starting with $) which must be replaced before running.
docker exec georegistry-orientdb bash -c 'bin/console.sh "connect remote:localhost/georegistry $ORIENTDB_ROOT_USER $ORIENTDB_ROOT_PASS; export database /orientdb/backup/$ORIENTDB_MAJOR_VERSION.json"'
The default orientdb root username is 'root'
The default orientdb root password is 'root'
The OrientDB major version should not include the fix version. For example, '3.2'.
Kill the Orient DB server
docker rm -f georegistry-orientdb
Remove all data inside the mounted volume
rm -rf data/orientdb/databases/*
Run Orient DB of the new version. This command includes variables (starting with $) which must be replaced before running.
docker run --name georegistry-orientdb2 -e ORIENTDB_ROOT_PASSWORD="$ORIENTDB_ROOT_PASS" -e ORIENTDB_OPTS_MEMORY="-Xms512M -Xmx2G" -d -v /data/orientdb/databases:/orientdb/databases -v /data/orientdb/backup:/orientdb/backup orientdb:$ORIENTDB_MAJOR_VERSION
Import the backup into the new Orient DB. This command includes variables (starting with $) which must be replaced before running.
docker exec georegistry-orientdb2 bash -c 'bin/console.sh "CREATE DATABASE remote:localhost/georegistry $ORIENTDB_ROOT_USER $ORIENTDB_ROOT_PASS; connect remote:localhost/georegistry $ORIENTDB_ROOT_USER $ORIENTDB_ROOT_PASS; import database /orientdb/backup/$ORIENTDB_MAJOR_VERSION.json.gz"'
Kill the temporary Orient DB server
docker rm -f georegistry-orientdb2
PostgreSQL Migration
Upgrading PostgreSQL is fairly straightforward and reliable.
The official PostgreSQL migration documenation can be found here:
https://www.postgresql.org/docs/current/upgrading.html#UPGRADING-VIA-PGDUMPALL
The basic steps for performing an upgrade on our default docker compose environment are as follows:
Stop the webserver with
docker stop georegistry
Run a new Postgres of the new version. This command includes variables (starting with $) which must be replaced before running.
docker run --name georegistry-postgres2 -d -p 5482:5432 --network $CGR_DOCKER_NETWORK --link georegistry-postgres -v /data/postgres-migrate:/var/lib/postgresql/data -e POSTGRES_PASSWORD=$POSTGRES_ROOT_PASSWORD postgis/postgis:$NEW_POSTGRES_VERSION
The default postgres root username is
postgres
.The default postgres root password is
georegistry
.The NEW_POSTGRES_VERSION variable is a Docker image tag and should also include a PostGIS version. For example, '14-3.2'.
The value for the CGR_DOCKER_NETWORK variable can be found by running
docker inspect georegistry-postgres
. The georegistry network name is autogenerated and will be listed in the "Networks" section of the inspect output.
Restore old Postgres into new Postgres. This command includes variables (starting with $) which must be replaced before running.
docker exec -t georegistry-postgres2 bash -c "(PGPASSWORD=$POSTGRES_ROOT_PASSWORD pg_dumpall --host georegistry-postgres --port 5432 --username postgres --no-password && echo -e \"\n\nALTER ROLE postgres PASSWORD '$POSTGRES_ROOT_PASSWORD';\" && echo -e \"\n\nALTER ROLE georegistry PASSWORD '$POSTGRES_APP_PASSWORD';\") | psql -d postgres --host 127.0.0.1 --port 5432 --username postgres --no-password"
The default Postgres app password is
georegistry
.
Delete temporary Postgres containers
docker rm -f georegistry-postgres && docker rm -f georegistry-postgres2
Delete the old Postgres data directory
rm -rf /data/postgres
Copy the postgres data from the new version to the standard directory
mv /data/postgres-migrate /data/postgres
Last updated