Difference between revisions of "Bacula"

From DHVLab

(Created page with "Bacula consists of multiple daemons. # Bacula Director (bacula-dir): controls the backup and restore operations that are performed by the File and Storage daemons # Storage D...")
 
Line 147: Line 147:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Configure Console ===
 
conf.d/console.conf
 
conf.d/console.conf
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
Line 155: Line 157:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Configure Catalog ===
 
Now we connect Bacula to the MySQL database throuth the <br/>
 
Now we connect Bacula to the MySQL database throuth the <br/>
 
conf.d/catalog.conf
 
conf.d/catalog.conf
Line 167: Line 171:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Configure Schedules ===
 
Next we specify Schedules for the backups  <br/>
 
Next we specify Schedules for the backups  <br/>
 
conf.d/schedules.conf
 
conf.d/schedules.conf
Line 181: Line 187:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Configure Job Defaults ===
 
Default values that can be used by our backup jobs are defined in the <br/>
 
Default values that can be used by our backup jobs are defined in the <br/>
 
conf.d/defjobs.conf
 
conf.d/defjobs.conf
Line 197: Line 205:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Configure Connection to Storage ===
 
conf.d/storage.conf
 
conf.d/storage.conf
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
Line 218: Line 228:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Configure Storage Pools ===
 
conf.d/pools.conf
 
conf.d/pools.conf
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">

Revision as of 18:41, 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

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
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               
}

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