]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #7623 About wrong versions reported by updatedb scripts
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Thu, 13 May 2021 05:17:18 +0000 (07:17 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:02 +0000 (09:03 +0100)
bacula/updatedb/update_postgresql_tables_1020_to_1021.in [new file with mode: 0644]
bacula/updatedb/update_postgresql_tables_1021_to_1022.in

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 (file)
index 0000000..66f1ecb
--- /dev/null
@@ -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} $* <<END-OF-DATA
+begin;
+UPDATE Version SET VersionId=1021;
+commit;
+END-OF-DATA
+then
+   echo "Update of Bacula PostgreSQL tables succeeded."
+else
+   echo "Update of Bacula PostgreSQL tables failed."
+fi
+
+exit 0
index 016f46e6da7f72a3d3cf3224a8a75016ee111f79..dea2fffa4cf1e4e66a15c80465c60d564c8f4703 100644 (file)
@@ -5,7 +5,7 @@
 #
 #
 echo " "
-echo "This script will update a Bacula PostgreSQL database from version 1020 to 1021"
+echo "This script will update a Bacula PostgreSQL database from version 1021 to 1022"
 echo " "
 
 bindir=@POSTGRESQL_BINDIR@