From: Michal Rakowski Date: Thu, 13 May 2021 05:17:18 +0000 (+0200) Subject: Fix #7623 About wrong versions reported by updatedb scripts X-Git-Tag: Release-11.3.2~540 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cef8b0c95f64c0b95aeed386dc82a606735e6e7;p=thirdparty%2Fbacula.git Fix #7623 About wrong versions reported by updatedb scripts --- diff --git a/bacula/updatedb/update_postgresql_tables_1020_to_1021.in b/bacula/updatedb/update_postgresql_tables_1020_to_1021.in new file mode 100644 index 000000000..66f1ecb23 --- /dev/null +++ b/bacula/updatedb/update_postgresql_tables_1020_to_1021.in @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Copyright (C) 2000-2020 Kern Sibbald +# License: BSD 2-Clause; see file LICENSE-FOSS +# +# +echo " " +echo "This script will update a Bacula PostgreSQL database from version 1020 to 1021" +echo " which is needed to convert from Bacula version 8.8 to 10.0" +echo " " + +bindir=@POSTGRESQL_BINDIR@ +PATH="$bindir:$PATH" +db_name=${db_name:-@db_name@} + +DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "select VersionId from Version" $*` +if [ $DBVERSION != 1020 ] ; then + echo " " + echo "The existing database is version $DBVERSION !!" + echo "This script can only update an existing version 1020 database to version 1021." + echo "Error. Cannot upgrade this database." + echo " " + exit 1 +fi + +if psql -f - -d ${db_name} $* <