Difference between revisions of "Bacula"

From DHVLab

 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:Backup]]
 
Bacula consists of multiple daemons.  
 
Bacula consists of multiple daemons.  
 
# Bacula Director (bacula-dir): controls the backup and restore operations that are performed by the File and Storage daemons
 
# Bacula Director (bacula-dir): controls the backup and restore operations that are performed by the File and Storage daemons
Line 4: Line 5:
 
# Catalog:  maintains a database of files that are backed up. The database is stored in MySQL
 
# Catalog:  maintains a database of files that are backed up. The database is stored in MySQL
 
# Bacula Console (bconsole): A CLI that allows the administrator to control the Bacula Director
 
# Bacula Console (bconsole): A CLI that allows the administrator to control the Bacula Director
 +
<br/>
 +
Find more sample configuration files here [https://github.com/linuskohl/DHVLab/tree/master/configfiles/general/bacula Bacula config files]<br/>
 +
Or have a look at the [http://wiki.bacula.org/doku.php official documentation]<br/>
 +
For running jobs manually or restoring backups see [http://www.bacula.org/5.0.x-manuals/en/console/console/Bacula_Console.html bacula console documentation]
  
 
== Layout ==
 
== Layout ==
Line 121: Line 126:
 
=== Configure Director ===
 
=== Configure Director ===
 
To keep things clean we seperate configuration sections into different files <br/>
 
To keep things clean we seperate configuration sections into different files <br/>
 +
As you will see, all the configuration is done in configuration files on the Bacula-Director.<br/>
 
bacula-fd.conf
 
bacula-fd.conf
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
Line 250: Line 256:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
== Enable the services on BACKUP ==
 
Now enable the required services on BACKUP
 
Now enable the required services on BACKUP
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 258: Line 264:
 
systemctl enable bacula-dir
 
systemctl enable bacula-dir
 
systemctl enable bacula-sd
 
systemctl enable bacula-sd
 +
systemctl enable bacula-fd
 +
</syntaxhighlight>
 +
 +
 +
== Sample host (NODE) ==
 +
=== Config on Bacula Director ===
 +
/etc/bacula/conf.d/fd-NODE.conf
 +
<syntaxhighlight lang="text">
 +
Client {
 +
  Name = fd-NODE
 +
  Address = NODEXX.nodes.YOUR_DOMAIN
 +
  FDPort = 9102
 +
  Catalog = MyCatalog
 +
  Password = XXXXXX
 +
  File Retention = 1 years
 +
  Job Retention = 6 months
 +
  AutoPrune = yes
 +
}
 +
FileSet {
 +
  Name = fs-NODE
 +
  Include {
 +
    File = /etc
 +
    File = /backup
 +
    File = /opt/tomcat
 +
    File = /var/lib/guacamole
 +
    File = /var/log/
 +
    Options {
 +
      signature = MD5
 +
      Compression = GZIP5
 +
    }
 +
  }
 +
}
 +
Pool {
 +
  Name = p-NODE-full
 +
  Use Volume Once = yes
 +
  Pool Type = Backup
 +
  LabelFormat = NODE-full-
 +
  AutoPrune = yes
 +
  Volume Retention = 1 year
 +
  Maximum Volumes = 15
 +
  Recycle = yes
 +
}
 +
Pool {
 +
  Name = p-NODE-incr
 +
  Use Volume Once = yes
 +
  Pool Type = Backup
 +
  LabelFormat = NODE-incr-
 +
  AutoPrune = yes
 +
  Volume Retention = 1 month
 +
  Maximum Volumes = 15
 +
  Recycle = yes
 +
}
 +
Pool {
 +
  Name = p-NODE-diff
 +
  Use Volume Once = yes
 +
  Pool Type = Backup
 +
  LabelFormat = NODE-diff-
 +
  AutoPrune = yes
 +
  Volume Retention = 14 days
 +
  Maximum Volumes = 15
 +
  Recycle = yes
 +
}
 +
Job {
 +
  Name = j-NODE
 +
  Client = fd-NODE
 +
  JobDefs = "DefaultJob"
 +
  Type = Backup
 +
  Level = Full
 +
  FileSet = fs-NODE
 +
  Schedule = MonthlyCycle
 +
  Pool = p-NODE-full
 +
  Full Backup Pool = p-NODE-full
 +
  Incremental Backup Pool = p-NODE-incr
 +
  Differential Backup Pool = p-NODE-diff
 +
  Write Bootstrap = "/var/spool/bacula/%n.bsr"
 +
}
 +
</syntaxhighlight>
 +
 +
=== Install File-Daemon ===
 +
<syntaxhighlight lang="bash">
 +
yum install bacula-fd
 +
</syntaxhighlight>
 +
/etc/bacula/bacula-fd.conf
 +
<syntaxhighlight lang="text">
 +
Director {
 +
  Name = backup-dir
 +
  Password = XXXXXX
 +
}
 +
Director {
 +
  Name = bacula-mon
 +
  Password = XXXXXX
 +
  Monitor = yes
 +
}
 +
FileDaemon {         
 +
  Name = fd-NODE
 +
  FDport = 9102 
 +
  WorkingDirectory = /var/spool/bacula
 +
  Pid Directory = /var/run
 +
  Maximum Concurrent Jobs = 20
 +
  FDAddress = NODE.nodes.YOUR_DOMAIN
 +
}
 +
Messages {
 +
  Name = Standard
 +
  director = backup-dir = all, !skipped, !restored
 +
}
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="bash">
 +
#enable service
 +
systemctl start bacula-fd
 
systemctl enable bacula-fd
 
systemctl enable bacula-fd
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 19:45, 10 September 2016

Bacula consists of multiple daemons.

  1. Bacula Director (bacula-dir): controls the backup and restore operations that are performed by the File and Storage daemons
  2. Storage Daemon (bacula-sd): Software that performs reads and writes on the storage devices used for backups
  3. Catalog: maintains a database of files that are backed up. The database is stored in MySQL
  4. Bacula Console (bconsole): A CLI that allows the administrator to control the Bacula Director


Find more sample configuration files here Bacula config files
Or have a look at the official documentation
For running jobs manually or restoring backups see bacula console documentation

Layout

  • The Bacula-Director runs on BACKUP. On the same host as the MariaDB instance for the Bacula-Catalog.
  • Then there are two Storage-Daemons, one on BACKUP, the other on OVIRT.
  • Then every other machine that needs files to be backed up need a running instance of the Bacula-File-Daemon
  • The VMs use the Storage-Daemon of BACKUP, the physical hosts the OVIRT one.
  • OVIRTs File-Daemon takes care of backing up the VM export backups, while OVIRT backs up SAN disks that are used inside the virtual environment.

BACKUP

Installation

yum install bacula-director bacula-storage bacula-console bacula-client mariadb-server
==== MariaDB ====
#setup MariaDB
systemctl enable mariadb
systemctl start mariadb
#let bacula create tables
/usr/libexec/bacula/grant_mysql_privileges
/usr/libexec/bacula/create_mysql_database -u root
/usr/libexec/bacula/make_mysql_tables -u bacula

#secure MariaDB
mysql_secure_installation

#secure bacula
mysql -u root -p
> UPDATE mysql.user SET Password=PASSWORD('BACULA_DB_PASSWORD') WHERE User='BACULA_USER';
> FLUSH PRIVILEGES;
> exit

#tell bacula to use MySQL instead of PostgreSQL
sudo alternatives --config libbaccats.so
# select /usr/lib64/libbaccats-mysql.so

Configure Storage Daemon

Tapes will be stored on a SAN disk that is mounted on /san, so we will create a directory /san/backup

mkdir /san/backup
#fix permissions
chown -R bacula:bacula /san/backup
sudo chmod -R 700 /san/backup

bacula-sd.conf

Storage {                             
  Name = backup-sd
  SDPort = 9103                  
  WorkingDirectory = "/var/spool/bacula"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
  SDAddress = BACKUP.DMZ.YOUR_DOMAIN
}
Director {
  Name = backup-dir
  Password = XXXXXXX
}
Director {
  Name = bacula-mon
  Password = XXXXXX
  Monitor = yes
}
Device {
  Name = SAN
  Media Type = SAN
  Archive Device = /san/backup/
  LabelMedia = yes
  Random Access = yes
  AutomaticMount = yes
  RemovableMedia = no
  AlwaysOpen = no
}
Messages {
  Name = Standard
  director = bacula-dir = all
}

Configure Console

bconsole.conf

Director {
  Name = backup-dir
  DIRport = 9101
  address = BACKUP.dmz.YOUR_DOMAIN
  Password = XXXXXX
}

Configure File-Daemon

bacula-fd.conf

Director {
  Name = backup-dir
  Password = XXXXXX
}
Director {
  Name = bacula-mon
  Password = XXXXXXX
  Monitor = yes
}
FileDaemon {
  Name = fd-s_backup
  FDport = 9102
  WorkingDirectory = /var/spool/bacula
  Pid Directory = /var/run
  Maximum Concurrent Jobs = 20
  FDAddress = localhost
}
Messages {
  Name = Standard
  director = bacula-dir = all, !skipped, !restored
}

Configure Director

To keep things clean we seperate configuration sections into different files
As you will see, all the configuration is done in configuration files on the Bacula-Director.
bacula-fd.conf

@/etc/bacula/conf.d/director.conf
@/etc/bacula/conf.d/console.conf
@/etc/bacula/conf.d/catalog.conf
@/etc/bacula/conf.d/messages.conf
@/etc/bacula/conf.d/schedules.conf
@/etc/bacula/conf.d/defjobs.conf
@/etc/bacula/conf.d/storage.conf
@/etc/bacula/conf.d/pools.conf

The first thing is the configuration of the director itself. connf.d/director.conf

Director {                            
  Name = backup-dir
  DIRport = 9101                
  QueryFile = "/etc/bacula/query.sql"
  WorkingDirectory = "/var/spool/bacula"
  PidDirectory = "/var/run"
  Maximum Concurrent Jobs = 1
  Password = XXXXXX
  Messages = Daemon
  DirAddress = BACKUP.dmz.YOUR_DOMAIN
}

Configure Console

conf.d/console.conf

Console {
  Name = bacula-mon
  Password = XXXXXXX
  CommandACL = status, .status
}

Configure Catalog

Now we connect Bacula to the MySQL database throuth the
conf.d/catalog.conf

Catalog {
  Name = YOUR_CATALOG
  dbdriver = "dbi:mysql"; 
  dbaddress = localhost; 
  dbname = "BACULA_DB"; 
  dbuser = "BACULA_DB_USER"; 
  dbpassword = "BACULA_DB_PASSWORD";
}

Configure Schedules

Next we specify Schedules for the backups
conf.d/schedules.conf

Schedule {
  Name = "MonthlyCycle"
  Run = Level=Full 1st mon at 1:05
  Run = Level=Differential mon at 1:05
  Run = Level=Incremental mon-sun at 16:35
}
Schedule {
  Name = "WeeklyCycleAfterBackup"
  Run = Full sun-sat at 3:00
}

Configure Job Defaults

Default values that can be used by our backup jobs are defined in the
conf.d/defjobs.conf

JobDefs {
  Name = "DefaultJob"
  Schedule = "MonthlyCycle"
  Storage = backup-sd
  Messages = Standard
}
JobDefs {
  Name = "DefaultJobCluster"
  Schedule = "MonthlyCycle"
  Storage = cluster-storage
  Messages = Standard
}

Configure Connection to Storage

conf.d/storage.conf

Storage {
  Name = backup-sd
  Address = localhost
  SDPort = 9103
  Password = XXXXXX
  Device = SAN
  Media Type = SAN
  Maximum Concurrent Jobs = 20
}
Storage {
  Name = cluster-storage
  Address = OVIRT.backup
  SDPort = 9103
  Password = XXXXXX
  Device = SAN_CLUSTER
  Media Type = SAN_CLUSTER
  Maximum Concurrent Jobs = 20
}

Configure Storage Pools

conf.d/pools.conf

Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes                       
  AutoPrune = yes                     
  Volume Retention = 365 days         
}
Pool {
  Name = File
  Pool Type = Backup
  Label Format = Local-
  Recycle = yes                       
  AutoPrune = yes                     
  Volume Retention = 365 days         
  Maximum Volume Bytes = 50G          
  Maximum Volumes = 100               
}

Enable the services on BACKUP

Now enable the required services on BACKUP

systemctl start bacula-dir
systemctl start bacula-sd
systemctl start bacula-fd
systemctl enable bacula-dir
systemctl enable bacula-sd
systemctl enable bacula-fd


Sample host (NODE)

Config on Bacula Director

/etc/bacula/conf.d/fd-NODE.conf

Client {
  Name = fd-NODE
  Address = NODEXX.nodes.YOUR_DOMAIN
  FDPort = 9102
  Catalog = MyCatalog
  Password = XXXXXX
  File Retention = 1 years
  Job Retention = 6 months
  AutoPrune = yes
}
FileSet {
  Name = fs-NODE
  Include {
    File = /etc
    File = /backup
    File = /opt/tomcat
    File = /var/lib/guacamole
    File = /var/log/
    Options {
      signature = MD5
      Compression = GZIP5
    }
  }
}
Pool {
  Name = p-NODE-full
  Use Volume Once = yes
  Pool Type = Backup
  LabelFormat = NODE-full-
  AutoPrune = yes
  Volume Retention = 1 year
  Maximum Volumes = 15
  Recycle = yes
}
Pool {
  Name = p-NODE-incr
  Use Volume Once = yes
  Pool Type = Backup
  LabelFormat = NODE-incr-
  AutoPrune = yes
  Volume Retention = 1 month
  Maximum Volumes = 15
  Recycle = yes
}
Pool {
  Name = p-NODE-diff
  Use Volume Once = yes
  Pool Type = Backup
  LabelFormat = NODE-diff-
  AutoPrune = yes
  Volume Retention = 14 days
  Maximum Volumes = 15
  Recycle = yes
}
Job {
  Name = j-NODE
  Client = fd-NODE
  JobDefs = "DefaultJob"
  Type = Backup
  Level = Full
  FileSet = fs-NODE
  Schedule = MonthlyCycle
  Pool = p-NODE-full
  Full Backup Pool = p-NODE-full
  Incremental Backup Pool = p-NODE-incr
  Differential Backup Pool = p-NODE-diff
  Write Bootstrap = "/var/spool/bacula/%n.bsr"
}

Install File-Daemon

yum install bacula-fd

/etc/bacula/bacula-fd.conf

Director {
  Name = backup-dir
  Password = XXXXXX
}
Director {
  Name = bacula-mon
  Password = XXXXXX
  Monitor = yes
}
FileDaemon {          
  Name = fd-NODE
  FDport = 9102   
  WorkingDirectory = /var/spool/bacula
  Pid Directory = /var/run
  Maximum Concurrent Jobs = 20
  FDAddress = NODE.nodes.YOUR_DOMAIN
}
Messages {
  Name = Standard
  director = backup-dir = all, !skipped, !restored
}
#enable service
systemctl start bacula-fd
systemctl enable bacula-fd