+++ /dev/null
-#!/bin/sh
-#
-# Copyright (C) 2000-2015 Kern Sibbald
-# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-# Shell script to update MySQL
-#
-echo " "
-echo "This script will update a Bacula MySQL database from version 12 to 13"
-echo " which is needed to convert from Bacula"
-echo " "
-bindir=@MYSQL_BINDIR@
-PATH="$bindir:$PATH"
-db_name=${db_name:-@db_name@}
-
-mysql $* -D ${db_name} -e "select VersionId from Version\G" >/tmp/$$
-DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$`
-if [ $DBVERSION != 12 ] ; then
- echo " "
- echo "The existing database is version $DBVERSION !!"
- echo "This script can only update an existing version 12 database to version 13."
- echo "Error. Cannot upgrade this database."
- echo " "
- exit 1
-fi
-
-if mysql $* -f <<END-OF-DATA
-USE ${db_name};
-CREATE TABLE RestoreObject (
- RestoreObjectId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- ObjectName BLOB NOT NULL,
- RestoreObject LONGBLOB NOT NULL,
- PluginName TINYBLOB NOT NULL,
- ObjectLength INTEGER DEFAULT 0,
- ObjectFullLength INTEGER DEFAULT 0,
- ObjectIndex INTEGER DEFAULT 0,
- ObjectType INTEGER DEFAULT 0,
- FileIndex INTEGER UNSIGNED DEFAULT 0,
- JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
- ObjectCompression INTEGER DEFAULT 0,
- PRIMARY KEY(RestoreObjectId),
- INDEX (JobId)
-);
-
-CREATE INDEX jobhisto_jobid_idx ON JobHisto (JobId);
-UPDATE Version SET VersionId=13;
-END-OF-DATA
-then
- echo "Update of Bacula MySQL tables succeeded."
-else
- echo "Update of Bacula MySQL tables failed."
-fi
-exit 0
+++ /dev/null
-#!/bin/sh
-#
-# Copyright (C) 2000-2015 Kern Sibbald
-# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-# Shell script to update PostgreSQL tables from Bacula
-#
-echo " "
-echo "This script will update a Bacula PostgreSQL database from version 12 to 13"
-echo " which is needed to convert from Bacula"
-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 != 12 ] ; then
- echo " "
- echo "The existing database is version $DBVERSION !!"
- echo "This script can only update an existing version 12 database to version 13."
- echo "Error. Cannot upgrade this database."
- echo " "
- exit 1
-fi
-
-if psql -f - -d ${db_name} $* <<END-OF-DATA
-BEGIN; -- Necessary for Bacula core
-CREATE TABLE RestoreObject (
- RestoreObjectId SERIAL NOT NULL,
- ObjectName TEXT NOT NULL,
- RestoreObject BYTEA NOT NULL,
- PluginName TEXT NOT NULL,
- ObjectLength INTEGER DEFAULT 0,
- ObjectFullLength INTEGER DEFAULT 0,
- ObjectIndex INTEGER DEFAULT 0,
- ObjectType INTEGER DEFAULT 0,
- FileIndex INTEGER DEFAULT 0,
- JobId INTEGER,
- ObjectCompression INTEGER DEFAULT 0,
- PRIMARY KEY(RestoreObjectId)
- );
-
-CREATE INDEX restore_jobid_idx on RestoreObject(JobId);
-UPDATE Version SET VersionId=13;
-COMMIT;
-END-OF-DATA
-then
- echo "Update of Bacula PostgreSQL tables succeeded."
-else
- echo "Update of Bacula PostgreSQL tables failed."
-fi
-exit 0
# Copyright (C) 2000-2015 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
-# Shell script to update MySQL tables from Bacula Community version
+# Shell script to update SQLite 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 "This script will update a Bacula SQLite database from version 12-14 to 15"
echo " "
echo "Depending on the current version of your catalog, you may have to run this script"
echo " multiple times"
if [ "$DBVERSION" = 14 ] ; then
sqlite3 $* ${db_name}.db <<END-OF-DATA
+BEGIN;
+
INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
('I', 'Incomplete Job',25);
-ALTER TABLE Media ADD COLUMN VolABytes BIGINT UNSIGNED DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolAPadding BIGINT UNSIGNED DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolHoleBytes BIGINT UNSIGNED DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolHoles INTEGER UNSIGNED DEFAULT 0;
-ALTER TABLE Media CHANGE VolWrites VolWrites BIGINT UNSIGNED;
+
+CREATE TABLE new_Media (
+ MediaId INTEGER,
+ VolumeName VARCHAR(128) NOT NULL,
+ Slot INTEGER DEFAULT 0,
+ PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+ MediaType VARCHAR(128) NOT NULL,
+ MediaTypeId INTEGER UNSIGNED REFERENCES MediaType DEFAULT 0,
+ LabelType TINYINT DEFAULT 0,
+ FirstWritten DATETIME DEFAULT 0,
+ LastWritten DATETIME DEFAULT 0,
+ LabelDate DATETIME DEFAULT 0,
+ VolJobs INTEGER UNSIGNED DEFAULT 0,
+ VolFiles INTEGER UNSIGNED DEFAULT 0,
+ VolBlocks INTEGER UNSIGNED DEFAULT 0,
+ VolMounts INTEGER UNSIGNED DEFAULT 0,
+ VolBytes BIGINT UNSIGNED DEFAULT 0,
+ VolParts INTEGER UNSIGNED DEFAULT 0,
+ VolErrors INTEGER UNSIGNED DEFAULT 0,
+ VolWrites BIGINT UNSIGNED DEFAULT 0,
+ VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
+ VolStatus VARCHAR(20) NOT NULL,
+ Enabled TINYINT DEFAULT 1,
+ Recycle TINYINT DEFAULT 0,
+ ActionOnPurge TINYINT DEFAULT 0,
+ VolRetention BIGINT UNSIGNED DEFAULT 0,
+ VolUseDuration BIGINT UNSIGNED DEFAULT 0,
+ MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
+ MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
+ MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
+ InChanger TINYINT DEFAULT 0,
+ StorageId INTEGER UNSIGNED REFERENCES Storage DEFAULT 0,
+ DeviceId INTEGER UNSIGNED REFERENCES Device DEFAULT 0,
+ MediaAddressing TINYINT DEFAULT 0,
+ VolReadTime BIGINT UNSIGNED DEFAULT 0,
+ VolWriteTime BIGINT UNSIGNED DEFAULT 0,
+ EndFile INTEGER UNSIGNED DEFAULT 0,
+ EndBlock INTEGER UNSIGNED DEFAULT 0,
+ LocationId INTEGER UNSIGNED REFERENCES Location DEFAULT 0,
+ RecycleCount INTEGER UNSIGNED DEFAULT 0,
+ InitialWrite DATETIME DEFAULT 0,
+ ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+ RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+ Comment TEXT,
+ VolABytes BIGINT UNSIGNED DEFAULT 0,
+ VolAPadding BIGINT UNSIGNED DEFAULT 0,
+ VolHoleBytes BIGINT UNSIGNED DEFAULT 0,
+ VolHoles INTEGER UNSIGNED DEFAULT 0,
+ PRIMARY KEY(MediaId)
+ );
+INSERT INTO new_Media (MediaId, VolumeName, Slot, PoolId, MediaType, MediaTypeId, LabelType, FirstWritten, LastWritten, LabelDate, VolJobs, VolFiles, VolBlocks, VolMounts, VolBytes, VolParts, VolErrors, VolWrites, VolCapacityBytes, VolStatus, Enabled, Recycle, ActionOnPurge, VolRetention, VolUseDuration, MaxVolJobs, MaxVolFiles, MaxVolBytes, InChanger, StorageId, DeviceId, MediaAddressing, VolReadTime, VolWriteTime, EndFile, EndBlock, LocationId, RecycleCount, InitialWrite, ScratchPoolId, RecyclePoolId, Comment) SELECT MediaId, VolumeName, Slot, PoolId, MediaType, MediaTypeId, LabelType, FirstWritten, LastWritten, LabelDate, VolJobs, VolFiles, VolBlocks, VolMounts, VolBytes, VolParts, VolErrors, VolWrites, VolCapacityBytes, VolStatus, Enabled, Recycle, ActionOnPurge, VolRetention, VolUseDuration, MaxVolJobs, MaxVolFiles, MaxVolBytes, InChanger, StorageId, DeviceId, MediaAddressing, VolReadTime, VolWriteTime, EndFile, EndBlock, LocationId, RecycleCount, InitialWrite, ScratchPoolId, RecyclePoolId, Comment FROM Media;
+DROP TABLE Media;
+ALTER TABLE new_Media RENAME TO Media;
+CREATE INDEX inx8 ON Media (PoolId);
CREATE TABLE Snapshot (
SnapshotId INTEGER UNSIGNED AUTO_INCREMENT,
Name TINYBLOB NOT NULL,
JobId INTEGER UNSIGNED DEFAULT 0,
- FileSetId INTEGER UNSIGNED DEFAULT 0;
+ FileSetId INTEGER UNSIGNED DEFAULT 0,
CreateTDate BIGINT NOT NULL,
CreateDate DATETIME NOT NULL,
ClientId INTEGER DEFAULT 0,
primary key (SnapshotId)
);
-CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device(255), Volume(255), Name(255));
+CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device, Volume, Name);
CREATE INDEX jobtdate_idx on JobHisto (JobTDate);
UPDATE Version SET VersionId=15;
+
+COMMIT;
END-OF-DATA
DBVERSION=15
fi
-
-END-OF-DATA