From e96e72674696752c5a15e7618677b704919f4dc8 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 24 Aug 2012 13:52:55 +0000 Subject: [PATCH] Add per client pools, storages, devices, mediatypes --- modules/bacula/manifests/client.pp | 1 + modules/bacula/manifests/node.pp | 7 ++ modules/bacula/manifests/storage-per-node.pp | 27 +++++++ modules/bacula/manifests/storage.pp | 31 ++++++++ modules/bacula/templates/bacula-dir.conf.erb | 72 +------------------ modules/bacula/templates/bacula-sd.conf.erb | 1 + modules/bacula/templates/per-client.conf.erb | 70 ++++++++++++++++++ .../templates/storage-per-client.conf.erb | 16 +++++ 8 files changed, 155 insertions(+), 70 deletions(-) create mode 100644 modules/bacula/manifests/storage-per-node.pp create mode 100644 modules/bacula/templates/storage-per-client.conf.erb diff --git a/modules/bacula/manifests/client.pp b/modules/bacula/manifests/client.pp index e7506bff..a718c812 100644 --- a/modules/bacula/manifests/client.pp +++ b/modules/bacula/manifests/client.pp @@ -1,4 +1,5 @@ class bacula::client inherits bacula { + @@bacula::storage-per-node { $::fqdn: } package { ['bacula-fd']: ensure => installed diff --git a/modules/bacula/manifests/node.pp b/modules/bacula/manifests/node.pp index c96e69df..5552627a 100644 --- a/modules/bacula/manifests/node.pp +++ b/modules/bacula/manifests/node.pp @@ -2,6 +2,13 @@ define bacula::node() { include bacula + $bacula_pool_name = $bacula::bacula_pool_name + $bacula_filestor_name = $bacula::bacula_filestor_name + $bacula_filestor_device = $bacula::bacula_filestor_device + $bacula_storage_address = $bacula::bacula_storage_address + $bacula_storage_port = $bacula::bacula_storage_port + $bacula_storage_secret = $bacula::bacula_storage_secret + $bacula_client_port = $bacula::bacula_client_port $bacula_ca_path = $bacula::bacula_ca_path $bacula_ssl_client_cert = $bacula::bacula_ssl_client_cert diff --git a/modules/bacula/manifests/storage-per-node.pp b/modules/bacula/manifests/storage-per-node.pp new file mode 100644 index 00000000..e8926eb2 --- /dev/null +++ b/modules/bacula/manifests/storage-per-node.pp @@ -0,0 +1,27 @@ +define bacula::storage-per-node() { + + include bacula + + $bacula_filestor_device = $bacula::bacula_filestor_device + $bacula_filestor_name = $bacula::bacula_filestor_name + $bacula_backup_path = $bacula::bacula_backup_path + + $bacula_client_name = "${name}-fd" + $client = $name + + file { + "/etc/bacula/storage-conf.d/${name}.conf": + content => template('bacula/storage-per-client.conf.erb'), + mode => '0440', + group => bacula, + notify => Exec['bacula-sd reload'], + ; + "${bacula_backup_path}/${name}": + ensure => directory, + mode => '0755', + owner => bacula, + group => bacula, + ; + } +} + diff --git a/modules/bacula/manifests/storage.pp b/modules/bacula/manifests/storage.pp index e6738672..7b1c1a83 100644 --- a/modules/bacula/manifests/storage.pp +++ b/modules/bacula/manifests/storage.pp @@ -9,6 +9,16 @@ class bacula::storage inherits bacula { enable => true, hasstatus => true, } + + # should wait on -sd to finish current backups, then restart + # since it does not support reload and restarting kills running + # jobs + exec { 'bacula-sd reload': + path => '/usr/bin:/usr/sbin:/bin:/sbin', + command => 'true', + refreshonly => true, + } + file { '/etc/bacula/bacula-sd.conf': content => template('bacula/bacula-sd.conf.erb'), mode => '0640', @@ -16,6 +26,17 @@ class bacula::storage inherits bacula { notify => Service['bacula-sd'] } + file { '/etc/bacula/storage-conf.d': + ensure => directory, + mode => '0755', + group => bacula, + purge => true, + force => true, + recurse => true, + source => 'puppet:///files/empty/', + notify => Exec['bacula-sd reload'] + } + @ferm::rule { 'dsa-bacula-sd-v4': domain => '(ip)', description => 'Allow bacula-sd access from director and clients', @@ -29,4 +50,14 @@ class bacula::storage inherits bacula { rule => 'proto tcp mod state state (NEW) dport (bacula-sd) @subchain \'bacula-sd\' { saddr ($HOST_DEBIAN_V6) ACCEPT; }', notarule => true, } + + file { '/etc/bacula/storage-conf.d/empty.conf': + content => '', + mode => '0440', + group => bacula, + notify => Exec['bacula-sd reload'] + } + + Bacula::Storage-per-Node<<| |>> + } diff --git a/modules/bacula/templates/bacula-dir.conf.erb b/modules/bacula/templates/bacula-dir.conf.erb index 4a4c52d8..fe2d5ee2 100644 --- a/modules/bacula/templates/bacula-dir.conf.erb +++ b/modules/bacula/templates/bacula-dir.conf.erb @@ -136,27 +136,6 @@ Messages { append = "/var/lib/bacula/log" = all, !skipped } -######################################################################## -# Storage config # -######################################################################## - -Storage { - Name = <%= bacula_filestor_name %> - Address = <%= bacula_storage_address %> - SDPort = <%= bacula_storage_port %> - Password = "<%= bacula_storage_secret %>" - Device = <%= bacula_filestor_device %> - Media Type = <%= bacula_filestor_name %> - Maximum Concurrent Jobs = 10 - - TLS Enable = yes - TLS Require = yes - TLS CA Certificate File = "<%= bacula_ca_path %>" - # This is a client certificate, used by the director to connect to the storage daemon - TLS Certificate = "<%= bacula_ssl_client_cert %>" - TLS Key = "<%= bacula_ssl_client_key %>" -} - ######################################################################## # Console, limited # ######################################################################## @@ -176,9 +155,6 @@ JobDefs { FileSet = "Standard Set" Schedule = "WeeklyCycle" Messages = Standard - Pool = <%=bacula_pool_name%> - Differential Backup Pool = <%=bacula_pool_name%>diff - Incremental Backup Pool = <%=bacula_pool_name%>inc Max Full Interval = 1 month Priority = 10 Write Bootstrap = "/var/lib/bacula/%c.bsr" @@ -193,57 +169,13 @@ JobDefs { Job { Name = "RestoreFiles" Type = Restore - Client = draghi.debian.org-fd + Client = <%=bacula_director_address%>-fd FileSet = "Standard Set" - Pool = <%=bacula_pool_name%> + Pool = full-<%=bacula_pool_name%>-<%=bacula_director_address%> Messages = Standard Where = /var/tmp/bacula-restores } -######################################################################## -# Pool definition # -######################################################################## -Pool { - Name = <%= bacula_pool_name %> - Pool Type = Backup - Storage = <%=bacula_filestor_name%> - Recycle = no - AutoPrune = yes - Volume Retention = 1 year - Label Format = "<%= bacula_pool_name %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" - Volume Use Duration = 23h - #Maximum Volume Jobs = 1 - Maximum Volume Bytes = 50G - Action On Purge = Truncate -} - -Pool { - Name = <%= bacula_pool_name %>diff - Pool Type = Backup - Storage = <%=bacula_filestor_name%> - Recycle = no - AutoPrune = yes - Volume Retention = 1 year - Label Format = "<%= bacula_pool_name %>diff.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" - Volume Use Duration = 23h - #Maximum Volume Jobs = 1 - Maximum Volume Bytes = 50G - Action On Purge = Truncate -} - -Pool { - Name = <%= bacula_pool_name %>inc - Pool Type = Backup - Storage = <%=bacula_filestor_name%> - Recycle = no - AutoPrune = yes - Volume Retention = 1 year - Label Format = "<%= bacula_pool_name %>inc.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" - Volume Use Duration = 23h - #Maximum Volume Jobs = 1 - Maximum Volume Bytes = 50G - Action On Purge = Truncate -} # Scratch pool definition Pool { diff --git a/modules/bacula/templates/bacula-sd.conf.erb b/modules/bacula/templates/bacula-sd.conf.erb index 11e5b084..c6d99732 100644 --- a/modules/bacula/templates/bacula-sd.conf.erb +++ b/modules/bacula/templates/bacula-sd.conf.erb @@ -62,3 +62,4 @@ Messages { Name = Standard director = <%= bacula_director_name %> = all } +@|"sh -c 'for f in /etc/bacula/storage-conf.d/*.conf ; do echo @${f} ; done'" diff --git a/modules/bacula/templates/per-client.conf.erb b/modules/bacula/templates/per-client.conf.erb index 9be2f42a..5451b460 100644 --- a/modules/bacula/templates/per-client.conf.erb +++ b/modules/bacula/templates/per-client.conf.erb @@ -9,6 +9,10 @@ Job { JobDefs = "Standardbackup" Client = <%= bacula_client_name %> + Pool = "poolfull-<%= bacula_pool_name %>-<%= client %>" + Differential Backup Pool = "pooldiff-<%= bacula_pool_name %>-<%= client %>" + Incremental Backup Pool = "poolinc-<%= bacula_pool_name %>-<%= client %>" + #Rerun Failed Levels = yes Reschedule On Error = yes Reschedule Interval = 4 hours @@ -38,3 +42,69 @@ Client { TLS Certificate = "<%= bacula_ssl_client_cert %>" TLS Key = "<%= bacula_ssl_client_key %>" } + +######################################################################## +# Storage config # +######################################################################## + +Storage { + Name = "<%= bacula_filestor_name %>-<%= client %>" + Address = <%= bacula_storage_address %> + SDPort = <%= bacula_storage_port %> + Password = "<%= bacula_storage_secret %>" + Device = "<%= bacula_filestor_device %>-<%= client %>" + Media Type = "<%= bacula_filestor_name %>-<%= client %>" + Maximum Concurrent Jobs = 10 + + TLS Enable = yes + TLS Require = yes + TLS CA Certificate File = "<%= bacula_ca_path %>" + # This is a client certificate, used by the director to connect to the storage daemon + TLS Certificate = "<%= bacula_ssl_client_cert %>" + TLS Key = "<%= bacula_ssl_client_key %>" +} + +######################################################################## +# Pool definition # +######################################################################## +Pool { + Name = "poolfull-<%=bacula_pool_name%>-<%= client %>" + Pool Type = Backup + Storage = "<%=bacula_filestor_name%>-<%= client %>" + Recycle = no + AutoPrune = yes + Volume Retention = 1 year + Label Format = "<%= bacula_pool_name %>-full-<%= client %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" + Volume Use Duration = 23h + Maximum Volume Jobs = 1 + Maximum Volume Bytes = 50G + Action On Purge = Truncate +} + +Pool { + Name = "pooldiff-<%=bacula_pool_name%>-<%= client %>" + Pool Type = Backup + Storage = "<%=bacula_filestor_name%>-<%= client %>" + Recycle = no + AutoPrune = yes + Volume Retention = 1 year + Label Format = "<%= bacula_pool_name %>-diff-<%= client %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" + Volume Use Duration = 23h + Maximum Volume Jobs = 1 + Maximum Volume Bytes = 50G + Action On Purge = Truncate +} + +Pool { + Name = "poolinc-<%=bacula_pool_name%>-<%= client %>" + Pool Type = Backup + Storage = "<%=bacula_filestor_name%>-<%= client %>" + Recycle = no + AutoPrune = yes + Volume Retention = 2 months + Label Format = "<%= bacula_pool_name %>-inc-<%= client %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}" + Volume Use Duration = 23h + Maximum Volume Jobs = 1 + Maximum Volume Bytes = 50G + Action On Purge = Truncate +} diff --git a/modules/bacula/templates/storage-per-client.conf.erb b/modules/bacula/templates/storage-per-client.conf.erb new file mode 100644 index 00000000..2ce10714 --- /dev/null +++ b/modules/bacula/templates/storage-per-client.conf.erb @@ -0,0 +1,16 @@ +## +## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. +## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git +## + +Device { + Name = "<%= bacula_filestor_device %>-<%= client %>" + Media Type = "<%= bacula_filestor_name %>-<%= client %>" + Archive Device = "<%= bacula_backup_path %>/<%= client %>" + LabelMedia = yes; + Random Access = Yes; + AutomaticMount = yes; + RemovableMedia = no; + AlwaysOpen = no; + Maximum Network Buffer Size = 524288 +} -- 2.39.2