Einführung
Bacula ist eine professionelle Backuplösung die mehr und mehr auch in grösseren Firmen benutzt wird. Da ich persönlich leider nur oberflächige Tutorials gefunden habe und dazu auch diese auch immer recht simpel gehalten sind, wollte ich hier eine etwas anderes Tutorial schreiben.
Wir installieren Bacula 2.2.4(aktuell ist 5.0.1) mit Support für PostgresSQL, werden dort ein 3Clients hinzufügen und anschliessend ein Zeitplan erstellen
Wenn man sich die Konfigurationsdateien von Bacula anschaut, sehen diese sehr verwirrend undurchsichtig aus, aber der erste Blick täuscht, nach relativ kurzer einarbeit, kann man dort schnell erste erfolge erzielen.
Vorbereitungen
Als erstes installieren wir die nötigen Pakete:
apt-get install bacula-director-pgsql bacula-sd-pgsql bacula-console bacula-fd postgresql
normalerweise sollte die Installation ohne Probleme durchlaufen. Während der Installation erstellt Bacula auch gleich die nötige Tabelle bacula mit den nötigen user bacula. Der Backupserver(bsvr) sollte eine feste IP-Adresse haben und die einzelnen Server die gebackupt werden sollte dies auch haben.
Backupstrategie
Konfiguration
Konfigurationsdateien
Die Konfiguraionsdateien befinden sich in /etc/bacula/ die beiden wichtigsten Dateien sind
bacula-dir.conf #Config-datei für den Director (der entscheidet was wann wo und wie zu machen ist) bacula-sd.conf #Config-datei für den Storage-Daemon (dort wird eingestellt wo was gesichert wird)
Es gibt noch 2 andere Configurationsdateien:
bacula-fd.conf #Config-datei für den file-daemon (dieser Überreicht die daten zu dem Server) bconsole.conf #Config-datei ist für die console um bacula zu steuern
Daemon |
Name der Config-Datei |
Beschreibung |
Steuert die anderen Daemons von Bacula. Enthält die einzelnen Jobs und die Zeitsteuerung etc |
||
Organisiert die einzelnen Speichermedien (Tape, Festpplatte, DVD-LW, etc) |
||
File-Daemon muss auf den zu Sichernden Rechnern istalliert werden, er liefert die Daten aus |
||
Einstellungen für die Console von Bacula, man kann dort Bacula steuern, Jobs starten/stoppen, Dateien wiederherstellen etc |
Es gib eine sehr gute englische Dokumentation zu Bacula, diese findet man hier
bacular.dir
#
# Default Bacula Director Configuration file
#
# The only thing that MUST be changed is to add one or more
# file or directory names in the Include directive of the
# FileSet resource.
#
# For Bacula release 2.4.4 (28 December 2008) -- debian 5.0
#
# You might also want to change the default email address
# from root to your address. See the "mail" and "operator"
# directives in the Messages resource.
#
Director { # define myself
Name = csfbackup2
DIRport = 9101 # where we listen for UA connections
QueryFile = "/etc/bacula/scripts/query.sql"
WorkingDirectory = "/var/lib/bacula"
PidDirectory = "/var/run/bacula"
Maximum Concurrent Jobs = 1
Password = "geheim1" # Console password
Messages = Daemon
DirAddress = 192.168.200.23
}
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Differential
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = Default
Priority = 10
}
#hier werden die einzelnen configs der server eingebudnen
@/etc/bacula/conf.d/csfdata
@/etc/bacula/conf.d/csfdavid
@/etc/bacula/conf.d/csfprojektdb2
@/etc/bacula/conf.d/csfericoas
@/etc/bacula/conf.d/csfericsolidus
# Backup the catalog database (after the nightly save)
Job {
Name = "BackupCatalog"
JobDefs = "DefaultJob"
Client = "csfbackup2"
Level = Full
FileSet="Catalog"
Schedule = "WeeklyCycleAfterBackup"
# This creates an ASCII copy of the catalog
# WARNING!!! Passing the password via the command line is insecure.
# see comments in make_catalog_backup for details.
# Arguments to make_catalog_backup are:
# make_catalog_backup <database-name> <user-name> <password> <host>
RunBeforeJob = "/etc/bacula/scripts/make_catalog_backup bacula bacula bacula localhost"
# This deletes the copy of the catalog
RunAfterJob = "/etc/bacula/scripts/delete_catalog_backup"
RunAfterJob = "/bin/umount /backup"
Write Bootstrap = "/var/lib/bacula/BackupCatalog.bsr"
Priority = 11 # run after main backup
}
Job {
Name = "RestoreFiles"
Type = Restore
Client=csfbackup2
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /restore
}
FileSet {
Name = "Full Set"
Include {
Options {
signature = MD5
}
File = /nfs/nocrypt/jgoerzen/work/bacula/debian/tmp-build-sqlite
}
Exclude {
File = /proc
File = /tmp
File = /.journal
File = /.fsck
}
}
# die Zeitplanung
Schedule {
Name = "WeeklyCycle"
Run = Level=Differential Pool=MoPool Monday at 20:10
Run = Level=Differential Pool=DiPool Tuesday at 20:10
Run = Level=Differential Pool=MiPool Wednesday at 20:10
Run = Level=Differential Pool=DoPool Thursday at 20:10
Run = Level=Full Pool=Fr1Pool 1st Friday at 20:10
Run = Level=Full Pool=Fr2Pool 2nd Friday at 20:10
Run = Level=Full Pool=Fr3Pool 3rd Friday at 20:10
Run = Level=Full Pool=Fr4Pool 4th Friday at 20:10
}
# Catalog-backup, wird benoetigt um Daten wieder her zu stellen
Schedule {
Name = "WeeklyCycleAfterBackup"
Run = Level=Differential Pool=MoPool Monday at 20:10
Run = Level=Differential Pool=DiPool Tuesday at 20:10
Run = Level=Differential Pool=MiPool Wednesday at 20:10
Run = Level=Differential Pool=DoPool Thursday at 20:10
Run = Level=Full Pool=Fr1Pool 1st Friday at 20:10
Run = Level=Full Pool=Fr2Pool 2nd Friday at 20:10
Run = Level=Full Pool=Fr3Pool 3rd Friday at 20:10
Run = Level=Full Pool=Fr4Pool 4th Friday at 20:10
}
# This is the backup of the catalog
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = /var/lib/bacula/bacula.sql
}
}
Client {
Name = csfbackup2
Address = 192.168.200.23
FDPort = 9102
Catalog = MyCatalog
Password = "geheim1" # password for FileDaemon
File Retention = 30 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}
Storage {
Name = File
# Do not use "localhost" here
Address = 192.168.200.23 # N.B. Use a fully qualified name here
SDPort = 9103
Password = "geheim1"
Device = FileStorage
Media Type = File
}
# Generic catalog service
Catalog {
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = "bacula"
}
Messages {
Name = Standard
mailcommand = "/usr/lib/bacula/bsmtp -h 192.168.200.11:25 -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = skr@call-surf.de = warning, error, fatal, mount, alert, security, notsaved, !terminate !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
}
#
# Message delivery for daemon messages (no job).
Messages {
Name = Daemon
mailcommand = "/usr/lib/bacula/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
# mail = root@localhost = all, !skipped
mail = skr@call-surf.de = warning, error, fatal, mount, alert, security, notsaved, !terminate !skipped
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
}
# Hier kommen die Pools
Pool {
Name = Default
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
}
Pool {
Name = MoPool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 6d
Maximum Volume Jobs = 0
}
Pool {
Name = DiPool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 6d
Maximum Volume Jobs = 0
}
Pool {
Name = MiPool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 6d
Maximum Volume Jobs = 0
}
Pool {
Name = DoPool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 6d
Maximum Volume Jobs = 0
}
Pool {
Name = Fr1Pool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 6d
Maximum Volume Jobs = 0
}
Pool {
Name = Fr2Pool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 27d
Maximum Volume Jobs = 0
}
Pool {
Name = Fr3Pool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 27d
Maximum Volume Jobs = 0
}
Pool {
Name = Fr4Pool
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 27d
Maximum Volume Jobs = 0
}
# Scratch pool definition
Pool {
Name = Scratch
Pool Type = Backup
}
#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
Name = csfbackup2
Password = "geheim1"
CommandACL = status, .status}asdf