OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/docker/prod/postgres-db-upgrade

34 lines
904 B

#!/bin/bash
set -e
set -o pipefail
CURRENT_PGVERSION="$(cat $PGDATA/PG_VERSION)"
NEW_PGVERSION="13"
if [ "$CURRENT_PGVERSION" == "$NEW_PGVERSION" ]; then
echo "Current and new postgres version are identical. Aborting."
exit 1
fi
export PGBINOLD="/usr/lib/postgresql/$CURRENT_PGVERSION/bin"
export PGBINNEW="/usr/lib/postgresql/$NEW_PGVERSION/bin"
export PGDATAOLD="$PGDATA"
if [ "$OPENPROJECT_INSTALLATION__TYPE" == "docker" ]; then
export PGDATANEW="$PGDATA-next"
else
export PGDATANEW="/var/lib/postgresql/$NEW_PGVERSION/main"
fi
if [ ! -d "$PGDATANEW" ]; then
echo "$PGDATANEW does not exist."
exit 1
fi
if [ ! -f "$PGDATANEW/PG_VERSION" ]; then
echo "Empty cluster found in $PGDATANEW. Generating cluster..."
PGBIN=$PGBINNEW PGDATA=$PGDATANEW ./docker/prod/postgres-db-init
fi
cd /var/lib/postgresql
su -m postgres -c "$PGBINNEW/pg_upgrade"
su -m postgres -c "./analyze_new_cluster.sh"