3 # Shell script to update MySQL Enterprise version 2.6.x to 4.0.x
4 # or Bacula Community version 5.0.x to 5.2.x
7 echo "This script will update a Bacula MySQL database from version 12 to 13"
8 echo " which is needed to convert from Bacula Enterprise version 2.6.x to 6.0.x"
9 echo " or Bacula Community version 5.0.x to 5.2.x"
15 mysql ${db_name} -e "select VersionId from Version\G" >/tmp/$$
16 DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$`
17 if [ $DBVERSION != 12 ] ; then
19 echo "The existing database is version $DBVERSION !!"
20 echo "This script can only update an existing version 12 database to version 13."
21 echo "Error. Cannot upgrade this database."
26 if mysql $* -f <<END-OF-DATA
29 CREATE TABLE RestoreObject (
30 RestoreObjectId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
31 ObjectName BLOB NOT NULL,
32 RestoreObject LONGBLOB NOT NULL,
33 PluginName TINYBLOB NOT NULL,
34 ObjectLength INTEGER DEFAULT 0,
35 ObjectFullLength INTEGER DEFAULT 0,
36 ObjectIndex INTEGER DEFAULT 0,
37 ObjectType INTEGER DEFAULT 0,
38 FileIndex INTEGER UNSIGNED DEFAULT 0,
39 JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
40 ObjectCompression INTEGER DEFAULT 0,
41 PRIMARY KEY(RestoreObjectId),
45 CREATE INDEX jobhisto_jobid_idx ON JobHisto (JobId);
47 ALTER TABLE File ADD COLUMN DeltaSeq smallint default 0;
50 INSERT INTO Version (VersionId) VALUES (14);
54 echo "Update of Bacula MySQL tables succeeded."
56 echo "Update of Bacula MySQL tables failed."