#!/bin/sh # # Copyright (C) 2000-2015 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS # # Shell script to update MySQL tables from Bacula Community version # 5.0.x, 5.2.x, 7.0.x # echo " " echo "This script will update a Bacula MySQL database from version 12-14 to 15" echo " " echo "Depending on the current version of your catalog," echo "you may have to run this script multiple times." echo " " bindir=@MYSQL_BINDIR@ PATH="$bindir:$PATH" db_name=@db_name@ ARGS=$* getVersion() { mysql $ARGS -D ${db_name} -e "select VersionId from Version LIMIT 1\G" >/tmp/$$ DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$` } 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 14 ] ; then echo " " echo "The existing database is version $DBVERSION !!" echo "This script can only update an existing version 12-14 version 15." echo "Error. Cannot upgrade this database." echo " " exit 1 fi # For all versions, we need to create the Index on Media(StorageId) # It may fail, but it's not a big problem # mysql $* -f </dev/null 2> /dev/null # CREATE INDEX media_storageid_idx ON Media (StorageId); # END-OF-DATA if [ "$DBVERSION" -eq 12 ] ; then if mysql $* -f <