Table of Contents

Bacula (the *nix backup solution)

This article describes the 5.0.x series

Bacula is an centralized backup system. I usually runs on linux (brodul only has exp. running it on linux). I can backup Gnu/Linux, UNIX, MacOS, Windows boxes.

The system is separated in more daemons:

- bacula-dir (director)

Director is the main daemon it controls other daemons, reads the Catalog which is a SQL database.

- bacula-sd (storage daemon)

It runs on the machine that stores data (backup) .

- bacula-fd (file daemon)

Runs on the client (the server to backup).

- bconsole

Is the program to control the director. (brodul recommends that you ssh to the machine running the director first or build a tunnel)

Configuration

bacula-dir

#
#  Brodul Bacula Director Configuration file
#
#  For Bacula release 5.0.3 (04 August 2010) -- ubuntu 10.04
#
#  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.
#

# XXX
# ===================
# BASIC CONFIGURATION
# ===================

Director {                            # define myself
  Name = {{parts.servers.backup}}-dir
  DIRport = {{parts.ports.bacula_dir}}                # 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 = "{{dir}}"         # Console password
  Messages = Daemon
}

# XXX
# =====================
# GENERAL CONFIGURATION
# =====================

# XXX
# ++++
# JOBS
# ++++

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Schedule = "WeeklyCycle"
  Storage = File
  Messages = Standard
  Pool = File
  Priority = 10
  Write Bootstrap = "/var/lib/bacula/%c.bsr"
}

JobDefs {
  Name = "DesktopJob"
  Type = Backup
  Level = Differential
  Schedule = "DesktopCycle"
  Storage = File
  Messages = Desktop
  Pool = File
  Priority = 10
  Write Bootstrap = "/var/lib/bacula/%c.bsr"
  Reschedule On Error = yes
  Reschedule Interval = 1 hour
  Reschedule Times = 60
}

# Backup the catalog database (after the nightly save)
Job {
  Name = "BackupCatalog"
  JobDefs = "DefaultJob"
  Level = Full
  Client = {{parts.servers.backup}}-fd
  FileSet="Catalog"
  Schedule = "WeeklyCycleAfterBackup"
  Pool = Default
  Full Backup Pool = Catalog-full
  # This creates an ASCII copy of the catalog
  # Arguments to make_catalog_backup.pl are:
  #  make_catalog_backup.pl <catalog-name>
  RunBeforeJob = " pg_dump bacula -f /var/lib/bacula/pg_dump-bacula.sql -x -O -F c"
  # This deletes the copy of the catalog
  RunAfterJob  = "rm /var/lib/bacula/pg_dump-bacula.sql"
  Write Bootstrap = "/var/lib/bacula/%n.bsr"
  Priority = 11                   # run after main backup
}

#
# Standard Restore template, to be changed by Console program
#  Only one such job is needed for all Jobs/Clients/Storage ...
#
# XXX: Do I need this ?
# Yes
#
Job {
  Name = "RestoreFiles"
  Type = Restore
  FileSet="{{parts.this.hostname}}-set"
  Client = {{parts.servers.backup}}-fd
  Storage = File
  Pool = Default
  Messages = Standard
  Where = /nonexistant/path/to/file/archive/dir/bacula-restores
}


Job {
  Name = backup-{{parts.this.hostname}}
  JobDefs = DefaultJob
  Client = {{parts.this.hostname}}-fd
  Storage = File
  Level = Incremental
  Pool = Default
  Full Backup Pool = {{parts.this.hostname}}-full
  Differential Backup Pool = {{parts.this.hostname}}-diff
  Incremental Backup Pool = {{parts.this.hostname}}-inc
  FileSet = "{{parts.this.hostname}}-set"
}

# XXX
# +++++++++
# FILE SETS
# +++++++++


# This is the backup of the catalog
FileSet {
  Name = "Catalog"
  Include {
    Options {
      signature = MD5
    }
    File = "/var/lib/bacula/pg_dump-bacula.sql"
  }
}

FileSet {
  Name = "{{parts.this.hostname}}-set"
  Include {
    Options {
      signature = SHA1
      compression = GZIP1
      noatime = yes
    }
    # Add paths to backup
    File = /etc
    File = /var/lib/munin
  }
}


# XXX
# +++++++++
# SCHEDULES
# +++++++++

#
# When to do the backups, full backup on first sunday of the month,
#  differential (i.e. incremental since full) every other sunday,
#  and incremental backups other days
Schedule {
  Name = "WeeklyCycle"
  Run = Full 1st sun at 12:00
  Run = Differential 2nd-5th sun at 12:00
  Run = Incremental mon-sat at 23:05
}

# This schedule does the catalog. It starts after the WeeklyCycle
Schedule {
  Name = "WeeklyCycleAfterBackup"
  Run = Full sun-sat at 23:59
}

Schedule {
  Name = "DesktopCycle"
  Run = Full 1st fri at 12:00
  Run = Differential 2nd-5th fri at 12:00
}


# XXX
# =======
# STORAGE
# =======

# Definition of file storage device
Storage {
  Name = File
# Do not use "localhost" here
  Address = {{parts.ips.backup}}                # N.B. Use a fully qualified name here
  SDPort = {{parts.ports.bacula_sd}}
  Password = "{{sd}}"
  Device = FileStorage
  Media Type = File
}


# XXX
# =======
# CATALOG
# =======

# Generic catalog service
Catalog {
  Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = "dbi:sqlite3"; dbaddress = 127.0.0.1; dbport =
  dbname = {{db_name}}; DB Address = "localhost"; dbuser = "{{db_user}}"; dbpassword = "{{db_password}}"
}


# XXX
# ========
# MESSAGES
# ========

# Reasonable message delivery -- send most everything to email address
#  and to the console
Messages {
  Name = Standard
#
# NOTE! If you send to two email or more email addresses, you will need
#  to replace the %r in the from field (-f part) with a single valid
#  email address in both the mailcommand and the operatorcommand.
#  What this does is, it sets the email address that emails would display
#  in the FROM field, which is by default the same email as they're being
#  sent to.  However, if you send email to more than one address, then
#  you'll have to set the FROM address manually, to a single address.
#  for example, a 'no-reply@mydomain.com', is better since that tends to
#  tell (most) people that its coming from an automated source.

#
  mailcommand = "/usr/lib/bacula/bsmtp -h localhost -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 = root@localhost = all, !skipped
  operator = root@localhost = mount
  console = all, !skipped, !saved

#
# WARNING! the following will create a file that you must cycle from
#          time to time as it will grow indefinitely. However, it will
#          also keep all your messages if they scroll off the console.
#
  append = "/var/lib/bacula/log" = all, !skipped
  catalog = all
}


#
# 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
  console = all, !skipped, !saved
  append = "/var/lib/bacula/log" = all, !skipped
}

Messages {
  Name = Desktop
  console = all, !saved
  catalog = all

}


# Default pool definition
Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # one year
}

# File Pool definition
Pool {
  Name = File
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # one year
  Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
  Maximum Volumes = 100               # Limit number of Volumes in Pool
}



# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
}

Pool {
  Name = Catalog-full
  Label Format = Catalog-full-
  Volume Retention = 6 months
  @/etc/bacula/pool_defaults.conf
}

Pool {
  Name = {{parts.this.hostname}}-full
  Label Format = {{parts.this.hostname}}-full-
  @/etc/bacula/pool_defaults.conf
  @/etc/bacula/pool_full_defaults.conf
}
Pool {
  Name = {{parts.this.hostname}}-diff
  Label Format = {{parts.this.hostname}}-diff-
  @/etc/bacula/pool_defaults.conf
  @/etc/bacula/pool_diff_defaults.conf
}
Pool {
  Name = {{parts.this.hostname}}-inc
  Label Format = {{parts.this.hostname}}-inc-
  @/etc/bacula/pool_defaults.conf
  @/etc/bacula/pool_inc_defaults.conf
}

# XXX
# =======
# CONSOLE
# =======

#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
  Name = {{parts.servers.backup}}-mon
  Password = "{{dir_mon}}"
  CommandACL = status, .status
}


# XXX
# =======
# CLIENTS
# =======

# Client (File Services) to backup

Client {
  Name = {{parts.this.hostname}}-fd
  Address = {{parts.this.ip}}
  FDPort = {{parts.ports.bacula_fd}}
  Catalog = MyCatalog
  Password = "{{parts.bacula.fd}}"          # password for FileDaemon
}

#The jobs, filesets, pools for clients are located in clients directories in one file per client

@|"sh -c 'cat /etc/bacula/clients/*.conf'"

Others

TODO