lightoze / puppet-bacula

Manage Bacula backup system with Puppet
2 stars 4 forks source link

Should a DB like mysql of postgresql be installed independently? #4

Open 030 opened 8 years ago

030 commented 8 years ago

I was assuming that bacula requires a database like mysql or postgresql, but when I search the repo there where no hits. Does bacula require a database? If true what do you suggest?

lightoze commented 8 years ago

Yes, it does require a database. This module only manages a part of Bacula configuration related to client agents, backup jobs and schedules, so you can scale that easily. You still have to manually configure director database, backup storage, etc. It would be nice to have it in the module, but it's not in my plans currently.

I guess you want to use a single master/storage server, in such case you can use this for a quick start (also install puppetlabs/postgresql module):

  include postgresql::server

  postgresql::server::db { 'bacula':
    user     => 'bacula',
    password => false,
  }

  include bacula::director
  include bacula::storage
  include bacula::console

  bacula::messages { 'Standard':
    lines_director => [
      'mailcommand = "/usr/sbin/bsmtp -h localhost -f \"From: \(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"',
      'operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"From: \(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"',
      'mail = hostmaster@example.com = all, !skipped',
      'operator = hostmaster@example.com = mount',
      'console = all, !skipped, !saved',
      'append = "/var/log/bacula/bacula.log" = all, !skipped',
      'catalog = all',
    ]
  }
  bacula::storage::device { 'storage':
    mediatype => 'File'
  }

It will create the database, but you still have to initialize it by running /usr/libexec/bacula/make_postgresql_tables.

Then create two files:

/etc/bacula/bacula-dir.conf.d/director.conf:

Catalog {
  Name = MainCatalog
  dbname = bacula; DB Address = ""; dbuser = "bacula"; dbpassword = ""
}

Pool {
  Name = Monthly
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Action On Purge = truncate
  Volume Retention = 3 months
  Maximum Volume Bytes = 10G
  Maximum Volumes = 10
  Label Format = "M-"
}

Pool {
  Name = Weekly
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Action On Purge = truncate
  Volume Retention = 3 weeks
  Maximum Volume Bytes = 10G
  Maximum Volumes = 10
  Label Format = "W-"
}

Pool {
  Name = Daily
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Action On Purge = truncate
  Volume Retention = 10 days
  Maximum Volume Bytes = 10G
  Maximum Volumes = 10
  Label Format = "D-"
}

# 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 = "MonthlyCycle"
  Run = Full 1st sun at 23:05
  Run = Differential 2nd-5th sun at 23:05
  Run = Incremental mon-sat at 23:05
}

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Schedule = "MonthlyCycle"
  Storage = "director.fqdn.name-storage"
  Pool = Monthly
  Differential Backup Pool = Weekly
  Incremental Backup Pool = Daily
  Messages = Standard
  Priority = 10
  Write Bootstrap = "/var/spool/bacula/%n.bsr"
}

/etc/bacula/bacula-sd.conf.d/storage.conf (backups will be stored in /bacula):

Device {                                                                                                                                                                                                                                           
  Name = "storage"                                                                                                                                                                                                                                 
  Media Type = File                                                                                                                                                                                                                                
  Archive Device = /bacula                                                                                                                                                                                                                         
  LabelMedia = yes                                                                                                                                                                                                                                 
  Random Access = yes                                                                                                                                                                                                                              
  AutomaticMount = yes                                                                                                                                                                                                                             
  RemovableMedia = no                                                                                                                                                                                                                              
  AlwaysOpen = no                                                                                                                                                                                                                                  
}   

After running Puppet once again you should be able to get bacula-dir and bacula-sd running. Then you can enable full backup of some node:

class { 'bacula::fullbackup':
  options => { 'JobDefs' => 'DefaultJob' },
}

P.S. file paths may very depending on Linux distribution.

lightoze commented 8 years ago

Ah, and one more important note - you need to have PuppetDB for this module because it relies on exported resources (https://docs.puppet.com/puppet/latest/reference/lang_exported.html).