diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-11-17 10:17:38 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-11-17 10:17:38 +0100 |
commit | a0b37c3f34db45cc5a67c4866eef9a5d130929e1 (patch) | |
tree | dbc4cc80e297836cc0d7e1d5adcc20a210c9efd2 | |
parent | 70d89c2cf7bc52e1c6d9505e44649b3ef1220c0c (diff) | |
download | bin-a0b37c3f34db45cc5a67c4866eef9a5d130929e1.tar.gz bin-a0b37c3f34db45cc5a67c4866eef9a5d130929e1.tar.xz |
upgrade_pg.sh: Support major upgrades
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x | upgrade_pg.sh | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/upgrade_pg.sh b/upgrade_pg.sh index 21ee18a..2d95eb2 100755 --- a/upgrade_pg.sh +++ b/upgrade_pg.sh @@ -2,16 +2,14 @@ set -e ## Set the old version that we want to upgrade from. -TO_VERSION=$(pacman -Q postgresql | grep -Po '(?<=postgresql )[0-9]\.[0-9]') +TO_VERSION=$(pacman -Q postgresql | grep -Po '(?<=postgresql )[0-9]+\.[0-9]') to_major=$(echo "$TO_VERSION" | awk -F'.' '{print $1}') to_minor=$(echo "$TO_VERSION" | awk -F'.' '{print $2}') -if [[ ${to_major} -ne 9 ]]; then +if [[ ${to_major} -ne 11 ]]; then echo "WARNING: major upgrade detected, aborting..." exit 1 fi -from_major="${to_major}" -from_minor="$((to_minor - 1))" -export FROM_VERSION="${from_major}.${from_minor}" +export FROM_VERSION="$(cat /var/lib/postgres/data/PG_VERSION)" # free space check used_space=$(df --local --output=pcent /var/lib/postgres/ | grep -Po '[0-9]{1,3}(?=%)') @@ -31,8 +29,8 @@ su - postgres -c 'mkdir /var/lib/postgres/data' su - postgres -c "initdb --locale $LANG -E UTF8 -D /var/lib/postgres/data" vimdiff "/var/lib/postgres/data/pg_hba.conf" "/var/lib/postgres/data-${FROM_VERSION}/pg_hba.conf" vimdiff "/var/lib/postgres/data/postgresql.conf" "/var/lib/postgres/data-${FROM_VERSION}/postgresql.conf" -cp -avx "/var/lib/postgres/data-${FROM_VERSION}/server.crt" "/var/lib/postgres/data/server.crt" -cp -avx "/var/lib/postgres/data-${FROM_VERSION}/server.key" "/var/lib/postgres/data/server.key" +#cp -avx "/var/lib/postgres/data-${FROM_VERSION}/server.crt" "/var/lib/postgres/data/server.crt" +#cp -avx "/var/lib/postgres/data-${FROM_VERSION}/server.key" "/var/lib/postgres/data/server.key" systemctl stop postgresql.service su - postgres -c "pg_upgrade -b /opt/pgsql-${FROM_VERSION}/bin/ -B /usr/bin/ -d /var/lib/postgres/data-${FROM_VERSION} -D /var/lib/postgres/data" systemctl daemon-reload |