software:bacula

Dies ist eine alte Version des Dokuments!


Backup mit Bacula

Bacula ist ein Netzwerkbackupsystem mit Client/Server-Architektur das Daten in einem heterogenen Netzwerk sichert.

Bacula unterstützt Linux-, Unix- und Windows-Backup-Clients, und eine Reihe von professionellen Backup-Geräte einschließlich Tape-Libraries. Administratoren und Betreiber können das System über eine Konsole, grafische Benutzeroberfläche oder Web-Schnittstelle konfigurieren. Als Backend werden MySQL, PostgreSQL oder SQLite für die Speicherung von Informationen verwendet.

Quelle: Wikipedia.

  • Bacula Community-Version: 3.0.0 (28.12.2008) → 5.0.0 (22.01.2010) bis 5.2.13: (20.02.2013) → 7.0.0 (29.03.2014) → 9.0.0 (7.7.2017) → bis dato. Aktivität
  • Bacula Enterprise Edition (Firma: Bacula Systems, Lizenz: )
  • Bareos (Firma: Bareos GmbH & Co. KG; Lizenz: AGPL v3): Bugfixes und Sicherheitsupdates werden vorrangig für Subscription-Kunden bereitgestellt. Fork von Bacula 5.2.13, Versionsübersicht, Aktivität

Bareos wurde (etwa 2010) von Bacula abgespalten, vorrangig aus der Unzufriedenheit heraus das neue Features nur in der Enterprise-Edition gelandet sind die nicht unter freier Lizenz steht. Aktuellere Windows-Clients werden z.B. nur gegen Bezahlung angeboten, bei Sourceforge ist maximal 5.2.10 erhältlich). Zudem sollte die Konfiguration einfacher und mit sinnvollen Standards versehen werden und ein intuitivere Bedienung (Weboberfläche) geschaffen werden.

Wann braucht man kommerzielle Versionen?

  1. Web-Oberfläche für Kunden?
  2. aktueller Windows-Client?
  3. spezielle plugins (Datenbanken, backend wie Ceph)?
  4. wenn man kein eigenes know-how hat (bzw. aufbauen will)

in Deutschland:

Bacula Schaubild

  • Catalogue (SQL-DB): Katalog der gesicherten Dateien und sonstige Daten, unterstützt werden: MySQL (bacula-director-mysql), PostgreSQL (bacula-director-pgsql) und SQLite (bacula-director-sqlite / bacula-director-sqlite3 )
  • Director (bacula-dir): Koordination der Komponenten, Steuerung, archiviert Daten im Katalog
  • Storage (bacula-sd): stellt Sicherungsplatz zur Verfügung, verwaltet Datenträger
  • File-daemon (bacula-fd): führt Sicherungs- und Rücksicherungaufträge aus. Gibts für Windows, Linux, MacOS, BSDs, … Unter Windows werden offene Dateien von dem Volume-shadow-copy-service gesichert.
  • Console: bacula-console,bacula-console-gnome, bacula-console-qt oder bacula-console-wx

Director und Catalog gibts einmal, die anderen Komponenten lassen sich beliebig (oft) verteilen.

  • Jobs: Ein Backup-Auftrag enthält/verweist auf:
    • 1 Client
    • 1 FileSet
    • einen Zeitplan (Schedule)
    • in einem Pool von Datenträgern.
  • FileSets: definiert welche Dateien gesichert werden.
  • Pools:
  • Schedules (Zeitpläne)

Siehe auch: Bacula Konfiguration

  • Acurate Backups (gelöschte Dateien werden beim Restore nicht wiederhergestellt):
  • Verschlüsselung der Daten (Bareos, …)
  • Hardware-Verschlüsselung von LTO4+ Laufwerken nutzbar, Modus AES256-GCM (nur Bareos; lädt Schlüssel in das Bandlaufwerk)
  • Netzwerk Bandbreiten Begrenzung (…)
  • Dateien über x Größe ausnehmen (Bareos)
  • Jobs mit exakt gleichen Parametern nochmal ausgeführt (rerun/rerun since): Bareos
  • All-Drives-Feature (Bareos): in Bacula müssen alle Dateisystem/Laufwerk explizit angegeben werden, neue Dateisystem oder Laufwerkbuchstaben müssen explizit angegeben werden, das feature in Bareos nimmt dies automatisch vor
  • Alle Komponenten laufen auf Windows (nur Bareos, Bacula nur FD): Director, storage-daemon und low-level-tool bextract (benötigt für sehr alte Windows-Dateien wo die Windows-ACLs intakt bleiben sollen)
  • Windows EFS filesystems (Bareos ab 13.4.x)
  • mehrere Jobs-IDs mit bconsole abbrechen (Bareos ab 13.2.x)
  • passive-Client nur in Bareos (ab 13.1.x) - Firewallproblematik siehe unten
  • Unterstützung des dedup-Dateisystems von Server 2012 (Bareos)
  • storage-daemon plugins (Bareos), Beispiel (de)Kompression auf dem SD
  • Bandbreitenlimitierung (Bacula 7.2.0, Bareos)

CA (fremde oder eigene):

TLS-PSK (Pre Shared Keys)

Mit dem feature „PKI Encryption“ können die Daten direkt auf dem fd/agent verschlüsselt werden (bevor sie zum storage daemon geschickt werden), das funktioniert über einen Public/Key-Schlüssel auf dem client, die Daten werden per AES-128 verschlüsselt.

Einschränkungen:

  • metadaten werden nicht verschlüsselt (Dateiname, Größe etc.)
  • der director könnte durch ein restore-job den Schlüssel ändern bzw. austauschen

Data Encryption (bacula) Data Encryption (bareos)

S3 Object storage wird nativ in Bacula Enterprise Edition ab Version 8.8 implementiert (Enterprise Bacula S3, Swift, CEPH and Cloud Storage Driver Quick Guide bzw. Scenario 7: Backup using the Cloud plugin).

In der community-Version geht das nur mit Umwegen: Bacula Cloud Backup whitepaper

Bareos: Rados (Ceph) Storage plugin () How to get good speed with Rados (Ceph) storage daemon.

  • vollständig (Vollbackup): alle Daten
  • differenziell: geänderte Daten seite letztem Vollbackup
  • inkrementell: geänderte Daten seit letzter Sicherung. Falls das letzte Vollbackup fehlt wird automatisch ein Vollbackup durchgeführt

labeling

Wenn ein Job den Status „is waiting for an appendable Volume“ anzeigt, muss auf der Console der Befehl „label“ eingeben werden. Bacula schickt auch eine eMail mit dem Betreff „ Bacula: Intervention needed for …“. Die Backup-Datei bekommt den Namen des Labels.

Firewalling und Anbindung von Internethosts

Firewalling

Wer muss wen erreichen?

  • Console → DIR:9101
  • DIR → SD:9103
  • DIR → FD:9102
  • FD → SD:9103

Eine Anbindung von Backupquellen (mit installiertem bacula-fd) im Internet ist mit Bacula möglich. Vorrausssetzung ist, das die Backupquellen den Storage-daemon (bacula-sd) erreichen können (in der Konfiguration Address und SDPort). Falls dieser im internen LAN steht und nur einen intern erreichbaren DNS-Hostnamen hat, muss dieser mit hosts-Datei umgebogen werden und eine Freigabe in der Firewall eingerichtet werden. Zu beachten ist, dass z. B. der Download beim Vollbackup sehr lange dauern kann und auch ein Restore bei einer geringen Uploadgeschwindigkeit sehr lange dauern wird. Zusätzlich sollte die Firewall-regeln (Verbindung von file-daemon zum storage-daemon) auch die IP enthalten damit der Dienst nicht für das ganze Internet erreichbar ist.

Bareos hat den Modus „passive Client“, der eine eingehende Verbindung vom file-daemon zum storage daemon (+DNS-Kenntnis wie man ihn erreicht) unnötig macht.

Es stehen verschiedene Möglichkeiten zum restore zur Verfügung, die häufigste Wahl ist das letzte Backup („5: Select the most recent backup for a client“) bzw. ein bestimmter Zeitpunkt („6: Select backup for a client before a specified time“).

Vollständige Liste der Möglichkeiten:

To select the JobIds, you have the following choices:
     1: List last 20 Jobs run
     2: List Jobs where a given File is saved
     3: Enter list of comma separated JobIds to select
     4: Enter SQL list command
     5: Select the most recent backup for a client
     6: Select backup for a client before a specified time
     7: Enter a list of files to restore
     8: Enter a list of files to restore before a specified time
     9: Find the JobIds of the most recent backup for a client
    10: Find the JobIds for a backup for a client before a specified time
    11: Enter a list of directories to restore for found JobIds
    12: Select full restore to a specified Job date
    13: Cancel

Das folgende Skript löscht alle wartenden Jobs:

#!/bin/bash
jobIds=`echo 'status dir running' | bconsole | fgrep 'is waiting' | awk '{print $1}'`
for i in $jobIds
do
    if [ -z `echo "$i" | grep '^[0-9]\+$'` ]
    then
        echo "Error: job ID $i is not a number!"
    else
        echo "Killing waiting Bacula job $i"
        echo "cancel jobid=$i" | bconsole
    fi
done

Quelle: https://www.cyberwizzard.nl/gentoo-linux/144-kill-all-waiting-backup-jobs-in-bacula.html

baculum Webconsole

FIXME

Wenn die bacula-console richtig konfiguriert ist kommt bei der Verbindung folgende Meldung:

Connecting to Director MY-BACULA:9101
1000 OK: bacula-dir Version: 1.38.11 (28 June 2006)

Die möglichen Kommandos bekommt man nach Eingabe von „help“:

Command    Description
  =======    ===========
  add        add media to a pool
  autodisplay autodisplay [on|off] -- console messages
  automount  automount [on|off] -- after label
  cancel     cancel [

Die grafische Konsole aus dem Ubuntu-Paket (bacula-console-qt) ist sehr zähflüssig in der Bedienung. Starten kann man sie mit dem Aufruf von bat, es muss im Aufrufverzeichnis eine Konfigurationsdatei unter dem Namen bat.conf existieren, diese kann man von der bconsole (/etc/bacula/bconsole.conf) nehmen.

FIXME

Der Traymonitor wird als „Restricted Director“ konfiguriert. Dazu vergibt man ein eigenes Passwort.

Achtung: Falls die Standard-ports (TCP 5901 bis 5903) geändert werden, solltes dieses in der /etc/services auch eingetragen werden! Ansonsten finden die Init-scripte das PID-file (dort steht die aktuelle Prozess-ID drin) nicht und man wundert sich warum Konfigurationsänderungen nicht übernommen werden. Grund ist das die Prozesse gar nicht gefunden werden und somit auch nicht neu starten, deshalb werden Konfigurationsänderungen auch nicht übernommen.

Bacula Konfigurationsdiagramm

  • Sektionen:
    • Director
      • Port 9101
      • Password: Passwort für die Console
    • JobDefs

Config-Datei per include einbinden (Übersichtlichkeit, Automatisierung):

# source everything under "/etc/bacula/conf.d"
@|"sh -c 'for f in /etc/bacula/conf.d/*.conf ; do echo @${f} ; done'"
  1. Name (Name) anpassen
  2. IP-Adresse (FDAddress) zum lauschen angeben
  3. Restricted Director für traymonitor konfigurieren

systemd-service

  • Bacula-fd systemd.service /etc/systemd/system/bacula-fd.service
  • systemctl daemon-reload
  • systemctl enable bacula-fd.service
# Systemd Bacula service file
#
# Copyright (C) 2000-2016 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# /lib/systemd/system/bacula-fd.service
#
# Description:
#    Used to start the bacula file daemon service (bacula-fd)
#
#    enable : systemctl enable bacula-fd
#    start : systemctl start bacula-fd
#
#

# from http://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Unit]
Description=Bacula File Daemon service
Requires=network.target
After=network.target
RequiresMountsFor=/var/lib/bacula /etc/bacula /usr/sbin /run/bacula

# from http://www.freedesktop.org/software/systemd/man/systemd.service.html
[Service]
Type=simple
User=root
Group=root
Environment="CONFIG=/etc/bacula/bacula-fd.conf"
EnvironmentFile=-/etc/default/bacula-fd
ExecStartPre=/usr/sbin/bacula-fd -t -c $CONFIG
ExecStart=/usr/sbin/bacula-fd -f -c $CONFIG
ExecReload=/bin/kill -HUP $MAINPID
SuccessExitStatus=15
StandardError=syslog

[Install]
WantedBy=multi-user.target
  1. Name (Name) anpassen
  2. IP-Adresse (SDAddress) zum lauschen angeben
  3. Restricted Director für traymonitor konfigurieren
  4. Storage für die Dateiablage konfigurieren.
    1. Name und Mediatype müssen in bacula-dir.conf übereinstimmen
    2. Standardmäßig ist hier die Dateiablage unter /tmp angegeben.
  1. Öffnen /etc/bacula/bconsole.conf
  2. Hostname (address) des directors eintragen
  3. Password (password) des directors eintragen

Dies geht über Client Run Before/After Jobs.

In der Standardeinstellung wird anhand des Passwort-hashes (per CRAM-MD5) überprüft ob eine Kommunikation erlaubt wird. Ansonsten wird die Kommunikation unverschlüsselt geführt.

Ab Bacula version 2.5.x ist SSL/TLS-Verschlüsselung möglich:

Nur Authentifizierung der Partner (keine Verschlüsselung der Nutzdaten!):

TLS Authenticate = yes 

Vollständige Verschlüsselung (Authentifizierung + Nutzdaten), siehe auch: Bacula TLS - Communications Encryption

TLS Enable = yes
TLS Require = yes    # enforce encrypted communication
Verify Peer = yes

Die Kommunikationspartner werden überprüft (Einstellung nur auf im Server-kontext möglich, also beim dir FIXME). Wenn nicht per TLS Allowed CN bestimmte Common-Names eingeschränkt sind, dann werden alle gültigen Zertifikate der im System bekannten Root-CAs akzeptiert.

TLS Allowed CN = 

Schränkt auf bestimmte Common-Names ein, die Direktive kann mehrfach angegeben werden.

TLS CA Certificate File = /etc/bacula/ca.pem   # This is a server certificate, used for incoming console connections
TLS Certificate = /etc/bacula/host.crt.pem     # public Certificate
TLS Key = /etc/bacula/host.key.pem          # private key

Konfigurations Beispiele Bacula

  1. bacula-fd.conf anlegen
  2. Passwort / IP / Name ändern
  3. die fd-Konfiguration anpassen
    1. In Client-Sektion die Daten aus der eben angelegten „bacula-fd.conf“ kopieren
    2. JobDefs
    3. Job
    4. Fileset

Der file-Daemon (Bezeichnung als „Client“ auf Windows).

#
# "Global" File daemon configuration specifications
#
FileDaemon {                            # this is me
  Name = windowSRV-fd
  FDport = 9102                # where we listen for the director
  WorkingDirectory = "C:/Dokumente und Einstellungen/All Users/Anwendungsdaten/Bacula/Work"
  Pid Directory = "C:/Dokumente und Einstellungen/All Users/Anwendungsdaten/Bacula/Work"
  Maximum Concurrent Jobs = 2
}

#
# List Directors who are permitted to contact this File daemon
#
Director {
  Name = bacula-dir
  Password = "Passwort_ändern!"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the file daemon
#
Director {
  Name = bacula-mon
  Password = "Passwort_ändern!"
  Monitor = yes
}

# Send all messages except skipped files back to Director
Messages {
  Name = Standard
  director = bacula-dir = all, !skipped, !restored
}
#
# List Directors who are permitted to contact this File daemon
#
Director {
  Name = bacula-dir
  Password = "Passwort_ändern!"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the file daemon
#
Director {
  Name = bacula-mon
  Password = "Passwort_ändern!"
  Monitor = yes
}

#
# "Global" File daemon configuration specifications
#
FileDaemon {                          # this is me
  Name = bacula-fd
  FDport = 9102                  # where we listen for the director
  WorkingDirectory = /var/lib/bacula
  Pid Directory = /var/run/bacula
  Maximum Concurrent Jobs = 20
  FDAddress = 127.0.0.1 # change!
}

# Send all messages except skipped files back to Director
Messages {
  Name = Standard
  director = bacula-dir = all, !skipped, !restored
}
#
# Bacula User Agent (or Console) Configuration File
#

Director {
  Name = bacula.pi4-director
  DIRport = 9101
  address = bacula.pi4
  Password = "Passwort_ändern!"
}

Problembehebung

Passt die Version des fd zum director/sd? → er därf älter sein aber nicht neuer! Evtl. muss der bacula-fd und bacula-common per downgrade auf eine ältere Version gebracht werden und per pinning vor updates geschützt werden.

Gründe

  1. Name des Directors ist in der Konfiguration des directors und des file-daemons unterschiedlich
  2. Passwort des file-daemons ist in der Konfiguration des directors und des file-daemons unterschiedlich
  3. nach Portänderungen wurde die Konfiguration nicht korrekt übernommen (veränderte Ports in /etc/services eintragen)
  4. „Maximum Concurrent Jobs“ wurde auf dem file-daemons überschritten und er lehnt zusätzliche Verbindungen ab
  5. hosts.allow or hosts.deny verbieten eine Kommunikation zwischen den Rechnern
  6. es existiert kein Reverse-lookup für die Adresse
  7. diverse Netzwerkprobleme
    1. funktioniert DNS?
    2. Ist der fd wirklich auf dem Zielrechner auf dem angegebenem Port (überprüfen mit lsof -i)
    3. Blockiert eine zwischengeschaltete Firewall die Kommunikation?
      1. der Director muss den fd erreichen können
      2. der fd muss den sd erreichen können (fd initiiert die Verbindung!)
    4. Routing-probleme

siehe auch: I'm Getting Authorization Errors. What is Going On? (Bacula-FAQ)

Per Shellskript die wartenden Jobs abbrechen:

#!/bin/bash
jobIds=`echo 'status dir running' | bconsole | fgrep 'is waiting' | awk '{print $1}'`
for i in $jobIds
do
    if [ -z `echo "$i" | grep '^[0-9]\+$'` ]
    then
        echo "Error: job ID $i is not a number!"
    else
        echo "Killing waiting Bacula job $i"
        echo "cancel jobid=$i" | bconsole
    fi
done

Alternativ: Max Wait Time

Quelle: Kill all waiting backup jobs in Bacula

z.B. falls der Datenträger voll war:

#!/bin/bash
 
for i in $(seq -w 00 68)
do
  if [ -z `echo "$i" | grep '^[0-9]\+$'` ]
  then
    echo "Error: job ID $i is not a number!"
  else
    echo "update volume=Bacula-Vol-00$i volstatus=append" | bconsole
  fi
done

Diese Fehlermeldung entsteht wenn die Komponenten von Bacula von der Versionsnummer her inkompatibel sind. Z.B. dann wenn der Director eine ältere Versionsnummer als der File-daemon hat. Wenn man den FD auf die gleiche Versionsnummer wie den Director bringt ist man auf der sicheren Seite. Wenn der file-daemon eine ältere Versionnummer als der Director hat sollte es trotzdem funktionieren. Siehe auch Kapitel DB-Upgrade.

Während der großen Versionssprünge kommt es zu Änderungen im Datenbank-layout. Die Tabelle Version zeigt die aktuelle Version des Layouts.

Die folgenden SQL-Befehle befinden sich u.a. im bacula-director-mysql-Paket von Debian wenn es entpackt wurde in der data.tar.gz im Verzeichnis /usr/share/dbconfig-common/data/bacula-director-mysql/upgrade/mysql bei anderen DB-Versionen analog.

Aktuelle DB-Version anzeigen:

SELECT * FROM Version;

DB-Upgrade auf Bacula 3.x , mir ist nicht bekannt welche minimale Version nötig ist, es funktioniert von Version 10 (z. B. Bacula 2.4.4) auf 11:

-- Fix bad index on Media table
DROP INDEX inx8 ON Media;
CREATE UNIQUE INDEX inx8 ON Media (VolumeName(128));
ALTER TABLE File CHANGE FileId FileId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE BaseFiles CHANGE FileId FileId BIGINT UNSIGNED NOT NULL;
ALTER TABLE Job ADD ReadBytes BIGINT UNSIGNED DEFAULT 0 AFTER JobBytes; 
ALTER TABLE Media ADD ActionOnPurge TINYINT DEFAULT 0 AFTER Recycle;
ALTER TABLE Pool ADD ActionOnPurge TINYINT DEFAULT 0 AFTER Recycle;
 
DELETE FROM Version;
INSERT INTO Version (VersionId) VALUES (11);
 
-- If you have already this table, you can remove it with:
-- DROP TABLE JobHistory;
 
-- Create a table like Job for long term statistics
CREATE TABLE JobHisto (
   JobId INTEGER UNSIGNED NOT NULL,
   Job TINYBLOB NOT NULL,
   Name TINYBLOB NOT NULL,
   TYPE BINARY(1) NOT NULL,
   Level BINARY(1) NOT NULL,
   ClientId INTEGER DEFAULT 0,
   JobStatus BINARY(1) NOT NULL,
   SchedTime DATETIME DEFAULT 0,
   StartTime DATETIME DEFAULT 0,
   EndTime DATETIME DEFAULT 0,
   RealEndTime DATETIME DEFAULT 0,
   JobTDate BIGINT UNSIGNED DEFAULT 0,
   VolSessionId INTEGER UNSIGNED DEFAULT 0,
   VolSessionTime INTEGER UNSIGNED DEFAULT 0,
   JobFiles INTEGER UNSIGNED DEFAULT 0,
   JobBytes BIGINT UNSIGNED DEFAULT 0,
   ReadBytes BIGINT UNSIGNED DEFAULT 0,
   JobErrors INTEGER UNSIGNED DEFAULT 0,
   JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
   PoolId INTEGER UNSIGNED DEFAULT 0,
   FileSetId INTEGER UNSIGNED DEFAULT 0,
   PriorJobId INTEGER UNSIGNED DEFAULT 0,
   PurgedFiles TINYINT DEFAULT 0,
   HasBase TINYINT DEFAULT 0,
   INDEX (StartTime)
   );

DB-Upgrade von Bacula 3.x auf 5.0 (Version 11 auf 12):

ALTER TABLE JobMedia DROP Copy ;
ALTER TABLE Job ADD COLUMN HasCache tinyint DEFAULT 0 after HasBase;
ALTER TABLE Job ADD COLUMN Reviewed tinyint DEFAULT 0 after HasCache;
ALTER TABLE Job ADD COLUMN Comment BLOB AFTER Reviewed;
ALTER TABLE JobHisto ADD COLUMN HasCache tinyint DEFAULT 0 after HasBase;
ALTER TABLE JobHisto ADD COLUMN Reviewed tinyint DEFAULT 0 after HasCache;
ALTER TABLE JobHisto ADD COLUMN Comment BLOB AFTER Reviewed;
 
ALTER TABLE STATUS ADD COLUMN Severity INT;
UPDATE STATUS SET Severity = 15;
UPDATE STATUS SET Severity = 100 WHERE JobStatus = 'f';
UPDATE STATUS SET Severity = 90 WHERE JobStatus = 'A';
UPDATE STATUS SET Severity = 10 WHERE JobStatus = 'T';
UPDATE STATUS SET Severity = 20 WHERE JobStatus = 'e';
UPDATE STATUS SET Severity = 25 WHERE JobStatus = 'E';
 
CREATE TABLE PathHierarchy
(
     PathId INTEGER NOT NULL,
     PPathId INTEGER NOT NULL,
     CONSTRAINT pathhierarchy_pkey PRIMARY KEY (PathId)
);
 
CREATE INDEX pathhierarchy_ppathid 
          ON PathHierarchy (PPathId);
 
CREATE TABLE PathVisibility
(
      PathId INTEGER NOT NULL,
      JobId INTEGER NOT NULL,
      SIZE int8 DEFAULT 0,
      Files int4 DEFAULT 0,
      CONSTRAINT pathvisibility_pkey PRIMARY KEY (JobId, PathId)
);
CREATE INDEX pathvisibility_jobid
             ON PathVisibility (JobId);
 
CREATE INDEX basefiles_jobid_idx ON BaseFiles ( JobId );
 
DELETE FROM Version;
INSERT INTO Version (VersionId) VALUES (12);

DB-Upgrade von Bacula 5.0 auf 5.2 (Version 14):

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);
 
ALTER TABLE File ADD COLUMN DeltaSeq SMALLINT DEFAULT 0;
 
DELETE FROM Version;
INSERT INTO Version (VersionId) VALUES (14);

DB-Upgrade von Bacula 5.2 auf 7.2.0 (Version auf 15):

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 Snapshot (
  SnapshotId	  INTEGER UNSIGNED AUTO_INCREMENT,
  Name		  TINYBLOB NOT NULL,
  JobId 	  INTEGER UNSIGNED DEFAULT 0,
  FileSetId	  INTEGER UNSIGNED DEFAULT 0,
  CreateTDate	  BIGINT   NOT NULL,
  CreateDate	  DATETIME NOT NULL,
  ClientId	  INTEGER UNSIGNED DEFAULT 0,
  Volume	  TINYBLOB NOT NULL,
  Device	  TINYBLOB NOT NULL,
  TYPE		  TINYBLOB NOT NULL,
  Retention	  INTEGER DEFAULT 0,
  Comment	  BLOB,
  PRIMARY KEY (SnapshotId)
);
 
CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device(255), Volume(255), Name(255));
 
CREATE INDEX jobtdate_idx ON JobHisto (JobTDate);
 
UPDATE Version SET VersionId=15;

DB-Upgrade von Bacula 7.2.x auf 9.0.x (Version 16):

ALTER TABLE BaseFiles MODIFY COLUMN BaseId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE Media CHANGE COLUMN VolParts VolType INTEGER UNSIGNED DEFAULT 0;
ALTER TABLE Media ADD COLUMN VolParts INTEGER DEFAULT 0;
ALTER TABLE Media ADD COLUMN VolCloudParts INTEGER DEFAULT 0;
ALTER TABLE Media ADD COLUMN LastPartBytes BIGINT DEFAULT 0;
ALTER TABLE Media ADD COLUMN CacheRetention BIGINT DEFAULT 0;
ALTER TABLE Pool  ADD COLUMN CacheRetention BIGINT DEFAULT 0;
 
 
-- If you switch to MySQL 5.7
ALTER TABLE Device ALTER COLUMN CleaningDate DROP DEFAULT;
ALTER TABLE Job    ALTER COLUMN SchedTime    DROP DEFAULT;
ALTER TABLE Job    ALTER COLUMN StartTime    DROP DEFAULT;
ALTER TABLE Job    ALTER COLUMN EndTime      DROP DEFAULT;
ALTER TABLE Job    ALTER COLUMN RealEndTime  DROP DEFAULT;
ALTER TABLE JobHisto ALTER COLUMN SchedTime  DROP DEFAULT;
ALTER TABLE JobHisto ALTER COLUMN StartTime  DROP DEFAULT;
ALTER TABLE JobHisto ALTER COLUMN EndTime    DROP DEFAULT;
ALTER TABLE JobHisto ALTER COLUMN RealEndTime DROP DEFAULT;
ALTER TABLE LocationLog ALTER COLUMN DATE DROP DEFAULT;
ALTER TABLE FileSet	ALTER COLUMN CreateTime DROP DEFAULT;
ALTER TABLE Media	ALTER COLUMN FirstWritten DROP DEFAULT;
ALTER TABLE Media	ALTER COLUMN LastWritten DROP DEFAULT;
ALTER TABLE Media	ALTER COLUMN LabelDate DROP DEFAULT;
ALTER TABLE Media	ALTER COLUMN InitialWrite DROP DEFAULT;
ALTER TABLE Log 	ALTER COLUMN TIME DROP DEFAULT;
# speeds up restore selection IF many files AND accurate
CREATE INDEX job_jobtdate_idx ON Job (JobTDate);
 
UPDATE Version SET VersionId=16;

DB-Fix 9.2.1-2:

### this IS extracted FROM src/cats/update_mysql_tables.in
### Authors comment:
# UPDATE version 16 TO be more robust FOR newer more
# strict MySQLs.  Note: this IS a post-FIRST release
# fix.
 
ALTER TABLE Device
   MODIFY CleaningDate DATETIME DEFAULT NULL;
ALTER TABLE File
   MODIFY FileIndex INTEGER DEFAULT 0;
ALTER TABLE RestoreObject
   MODIFY FileIndex INTEGER DEFAULT 0;
ALTER TABLE BaseFiles
   MODIFY FileIndex INTEGER DEFAULT 0;
ALTER TABLE Media
   MODIFY FirstWritten DATETIME DEFAULT NULL,
   MODIFY LastWritten DATETIME DEFAULT NULL,
   MODIFY LabelDate DATETIME DEFAULT NULL,
   MODIFY InitialWrite DATETIME DEFAULT NULL;
ALTER TABLE Job
   MODIFY SchedTime DATETIME DEFAULT NULL,
   MODIFY StartTime DATETIME DEFAULT NULL,
   MODIFY EndTime DATETIME DEFAULT NULL,
   MODIFY RealEndTime DATETIME DEFAULT NULL;
ALTER TABLE JobHisto
   MODIFY SchedTime DATETIME DEFAULT NULL,
   MODIFY StartTime DATETIME DEFAULT NULL,
   MODIFY EndTime DATETIME DEFAULT NULL,
   MODIFY RealEndTime DATETIME DEFAULT NULL;
ALTER TABLE LocationLog
   MODIFY DATE DATETIME DEFAULT NULL;
ALTER TABLE CDImages
   MODIFY LastBurn DATETIME DEFAULT NULL;
 
# Permit catalog TO contain negative FileIndexes
 
ALTER TABLE File
   MODIFY FileIndex INTEGER DEFAULT 0;
ALTER TABLE RestoreObject
   MODIFY FileIndex INTEGER DEFAULT 0;
ALTER TABLE BaseFiles
   MODIFY FileIndex INTEGER DEFAULT 0;