updatedb/update_postgresql_tables_11_to_12 \
updatedb/update_postgresql_tables_1021_to_1022 \
updatedb/update_postgresql_tables_1022_to_1023 \
+ updatedb/update_postgresql_tables_1023_to_1024 \
updatedb/update_mysql_tables_1020_to_1021 \
updatedb/update_mysql_tables_1021_to_1022 \
updatedb/update_mysql_tables_1022_to_1023 \
+ updatedb/update_mysql_tables_1023_to_1024 \
examples/nagios/check_bacula/Makefile \
platforms/rpms/redhat/bacula.spec \
platforms/rpms/redhat/bacula-bat.spec \
echo "Creating bacula tables..."
%{script_dir}/make_mysql_tables
- elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1015" ]; then
+ elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1024" ]; then
echo "This release requires an upgrade to your bacula database."
echo "Backing up your current database..."
mysqldump -f --opt bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2
echo "Granting privileges for PostgreSQL user bacula..."
su - postgres -c %{script_dir}/grant_postgresql_privileges
- elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1015" ]; then
+ elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1024" ]; then
echo "This release requires an upgrade to your bacula database."
echo "Backing up your current database..."
su - postgres -c 'pg_dump bacula' | bzip2 > %{working_dir}/bacula_backup.sql.bz2
echo "Creating bacula tables..."
%{script_dir}/make_mysql_tables
- elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1015" ]; then
+ elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1024" ]; then
echo "This release requires an upgrade to your bacula database."
echo "Backing up your current database..."
mysqldump -f --opt bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2
echo "Granting privileges for PostgreSQL user bacula..."
su - postgres -c %{script_dir}/grant_postgresql_privileges
- elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1015" ]; then
+ elif [ "$DB_VER" -ge "12" -a "$DB_VER" -lt "1024" ]; then
echo "This release requires an upgrade to your bacula database."
echo "Backing up your current database..."
su - postgres -c 'pg_dump bacula' | bzip2 > %{working_dir}/bacula_backup.sql.bz2
*/
/* Current database version number for all drivers */
-#define BDB_VERSION 1023
+#define BDB_VERSION 1024
typedef void (DB_LIST_HANDLER)(void *, const char *);
typedef int (DB_RESULT_HANDLER)(void *, int, char **);
);
-- Initialize Version
-INSERT INTO Version (VersionId) VALUES (1023);
+INSERT INTO Version (VersionId) VALUES (1024);
END-OF-DATA
then
create index object_type_idx on Object (ObjectType);
create index object_name_idx on Object (ObjectName);
create index object_source_idx on Object (ObjectSource);
+create index object_status_idx on Object (ObjectStatus);
CREATE TABLE Events
(
Volume text_pattern_ops,
Name text_pattern_ops);
-INSERT INTO Version (VersionId) VALUES (1023);
+INSERT INTO Version (VersionId) VALUES (1024);
-- Make sure we have appropriate permissions
('I', 'Incomplete Job',25);
-- Initialize Version
-INSERT INTO Version (VersionId) VALUES (1023);
+INSERT INTO Version (VersionId) VALUES (1024);
PRAGMA default_cache_size = 100000;
PRAGMA synchronous = NORMAL;
fi
fi
+if [ "$DBVERSION" -eq 1023 ] ; then
+ if mysql $* -f <<END-OF-DATA
+USE ${db_name};
+ALTER TABLE Object ADD ObjectStatus BINARY(1) DEFAULT 'U';
+ALTER TABLE Object ADD ObjectCount INTEGER UNSIGNED DEFAULT 1;
+create index object_status_idx on Object (ObjectStatus);
+UPDATE Version SET VersionId=1024;
+END-OF-DATA
+ then
+ echo "Update of Bacula MySQL tables 1023 to 1024 succeeded."
+ getVersion
+ else
+ echo "Update of Bacula MySQL tables 1023 to 1024 failed."
+ exit 1
+ fi
+fi
+
exit 0
fi
fi
+if [ "$DBVERSION" -eq 1023 ] ; then
+ if psql -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+ALTER TABLE Object ADD COLUMN ObjectStatus char(1) default 'U';
+ALTER TABLE Object ADD COLUMN ObjectCount integer default 1;
+create index object_status_idx on Object (ObjectStatus);
+UPDATE Version SET VersionId=1024;
+commit;
+END-OF-DATA
+ then
+ echo "Update of Bacula PostgreSQL tables 1023 to 1024 succeeded."
+ getVersion
+ else
+ echo "Update of Bacula PostgreSQL tables 1023 to 1024 failed."
+ exit 1
+ fi
+fi
#
# For all versions, we need to create the Index on Media(PoolId/StorageId)
exit 1
fi
fi
+
+if [ "$DBVERSION" -eq 1023 ] ; then
+ if sqlite3 -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+ALTER TABLE Object ADD COLUMN ObjectStatus char(1) default 'U';
+ALTER TABLE Object ADD COLUMN ObjectCount integer default 1;
+create index object_status_idx on Object (ObjectStatus);
+UPDATE Version SET VersionId=1024;
+commit;
+END-OF-DATA
+ then
+ echo "Update of Bacula SQLite3 tables 1023 to 1024 succeeded."
+ DBVERSION=1023
+ else
+ echo "Update of Bacula SQLite3 tables 1023 to 1024 failed."
+ exit 1
+ fi
+fi
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2021 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 1023 to 1024"
+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 != 1023 ] ; then
+ echo " "
+ echo "The existing database is version $DBVERSION !!"
+ echo "This script can only update an existing version 1023 database to version 1024."
+ echo "Error. Cannot upgrade this database."
+ echo " "
+ exit 1
+fi
+
+if mysql $* -f <<END-OF-DATA
+USE ${db_name};
+ALTER TABLE Object ADD ObjectStatus BINARY(1) DEFAULT 'U';
+ALTER TABLE Object ADD ObjectCount INTEGER UNSIGNED DEFAULT 1;
+create index object_status_idx on Object (ObjectStatus);
+UPDATE Version SET VersionId=1024;
+END-OF-DATA
+then
+ echo "Update of Bacula MySQL tables 1023 to 1024 succeeded."
+ getVersion
+else
+ echo "Update of Bacula MySQL tables 1023 to 1024 failed."
+ exit 1
+fi
+
+exit 0
#
#
echo " "
-echo "This script will update a Bacula PostgreSQL database from version 1020 to 1021"
+echo "This script will update a Bacula PostgreSQL database from version 1022 to 1023"
echo " "
bindir=@POSTGRESQL_BINDIR@
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2021 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+#
+echo " "
+echo "This script will update a Bacula PostgreSQL database from version 1023 to 1024"
+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 != 1023 ] ; then
+ echo " "
+ echo "The existing database is version $DBVERSION !!"
+ echo "This script can only update an existing version 1023 database to version 1024."
+ echo "Error. Cannot upgrade this database."
+ echo " "
+ exit 1
+fi
+
+if psql -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+ALTER TABLE Object ADD COLUMN ObjectStatus char(1) default 'U';
+ALTER TABLE Object ADD COLUMN ObjectCount integer default 1;
+create index object_status_idx on Object (ObjectStatus);
+UPDATE Version SET VersionId=1024;
+commit;
+END-OF-DATA
+then
+ echo "Update of Bacula PostgreSQL tables 1023 to 1024 succeeded."
+ getVersion
+else
+ echo "Update of Bacula PostgreSQL tables 1023 to 1024 failed."
+ exit 1
+fi
+
+exit 0