X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fupdate_postgresql_tables.in;h=aa6400e075b688898f0d7dbd732dc5a899c9d3b4;hb=70cf799aa79d4c1ee8961bc8c631c013214de738;hp=e4809e0605ec855407079a908cad70b6647bef2c;hpb=23c05544db72e3914843fef26036c161a8141e7e;p=bacula%2Fbacula diff --git a/bacula/src/cats/update_postgresql_tables.in b/bacula/src/cats/update_postgresql_tables.in index e4809e0605..aa6400e075 100644 --- a/bacula/src/cats/update_postgresql_tables.in +++ b/bacula/src/cats/update_postgresql_tables.in @@ -1,29 +1,51 @@ #!/bin/sh # -# Shell script to update PostgreSQL tables from version 12 to 13 -# or Bacula Community version 5.0.x to 5.2.x +# Copyright (C) 2000-2017 Kern Sibbald +# License: BSD 2-Clause; see file LICENSE-FOSS # +# Shell script to update PostgreSQL tables from Bacula Community version +# 5.0.x, 5.2.x, 7.0.x, 7.2.x, 7.4.x +# +echo " " +echo "This script will update a Bacula PostgreSQL database from version 12-15 to 16" echo " " -echo "This script will update a Bacula PostgreSQL database from version 12 to 13" -echo " which is needed to convert from Bacula Enterprise version 2.6.x to 4.0.x" -echo " or Bacula Community version 5.0.x to 5.2.x" +echo "Depending on the current version of your catalog," +echo "you may have to run this script multiple times." echo " " bindir=@POSTGRESQL_BINDIR@ PATH="$bindir:$PATH" db_name=@db_name@ -DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "select VersionId from Version" $*` -if [ $DBVERSION != 12 ] ; then - echo " " - echo "The existing database is version $DBVERSION !!" - echo "This script can only update an existing version 12 database to version 13." - echo "Error. Cannot upgrade this database." - echo " " - exit 1 +ARGS=$* + +getVersion() +{ + DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "select VersionId from Version LIMIT 1" $ARGS` +} + +getVersion + +if [ "x$DBVERSION" = x ]; then + echo + echo "Unable to detect database version, you can specify connection information" + echo "on the command line." + echo "Error. Cannot upgrade this database." + exit 1 +fi + +if [ "$DBVERSION" -lt 12 -o "$DBVERSION" -gt 15 ] ; then + echo " " + echo "The existing database is version $DBVERSION !!" + echo "This script can only update an existing version 12-15 database to version 16." + echo "Error. Cannot upgrade this database." + echo " " + exit 1 fi -if psql -f - -d ${db_name} $* <