3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Shell script to update PostgreSQL tables from Bacula
9 echo "This script will update a Bacula PostgreSQL database from version 12 to 13"
10 echo " which is needed to convert from Bacula"
13 bindir=@POSTGRESQL_BINDIR@
15 db_name=${db_name:-@db_name@}
17 DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "select VersionId from Version" $*`
18 if [ $DBVERSION != 12 ] ; then
20 echo "The existing database is version $DBVERSION !!"
21 echo "This script can only update an existing version 12 database to version 13."
22 echo "Error. Cannot upgrade this database."
27 if psql -f - -d ${db_name} $* <<END-OF-DATA
28 BEGIN; -- Necessary for Bacula core
29 CREATE TABLE RestoreObject (
30 RestoreObjectId SERIAL NOT NULL,
31 ObjectName TEXT NOT NULL,
32 RestoreObject BYTEA NOT NULL,
33 PluginName TEXT 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 DEFAULT 0,
40 ObjectCompression INTEGER DEFAULT 0,
41 PRIMARY KEY(RestoreObjectId)
44 CREATE INDEX restore_jobid_idx on RestoreObject(JobId);
45 UPDATE Version SET VersionId=13;
49 echo "Update of Bacula PostgreSQL tables succeeded."
51 echo "Update of Bacula PostgreSQL tables failed."