echo "this script may take several minutes to run."
echo " "
-bindir=/home/kern/bacula/depkgs/sqlite
-cd /home/kern/bacula/working
+bindir=/usr/bin
-$bindir/sqlite $* bacula.db <<END-OF-DATA
+# The location of your bacula working directory
+workdir=/var/lib/bacula
+
+
+cd $workdir
+
+if [ ! -r bacula.db -o ! -s bacula.db ];then
+ echo "Sorry, can't find a Bacula DB. Aborting."
+ exit 1
+fi
+
+DB_VER="`echo "select * from Version;" | $bindir/sqlite bacula.db | tail -1 2>/dev/null`"
+if [ -n "$DB_VER" ]; then
+
+ if [ "$DB_VER" = "8" ]; then
+ echo "The Catalog is already at version 8. Nothing to do!"
+ exit 0
+ elif [ "$DB_VER" -ne "7" ]; then
+ echo "Sorry, this script is designed to update a version 7 database"
+ echo "and you have a version $DB_VER database."
+ exit 1
+ fi
+
+else
+ echo "Sorry, I can't seem to locate a bacula database."
+ exit 1
+fi
+
+
+$bindir/sqlite $* bacula.db <<END_OF_DATA
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE Media_backup (
DROP TABLE Media_backup;
+CREATE INDEX inx9 ON File (JobId, PathId, FileNameId);
+
COMMIT;
UPDATE Filename SET Name='' WHERE Name=' ';
DELETE FROM Version;
INSERT INTO Version (VersionId) VALUES (8);
-END-OF-DATA
+END_OF_DATA