From ac4501b1c22d3fdd02fdc3eeb543d7069a56c8ef Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Wed, 16 Oct 2013 21:41:12 +0400 Subject: [PATCH 1/9] Add percona database support Fix ubuntu support --- manifests/director.pp | 8 +++++++- manifests/director/mysql.pp | 41 ++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/manifests/director.pp b/manifests/director.pp index fa51564..5a86be5 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -235,10 +235,16 @@ require => $service_require, } + if $::osfamily == 'Debian' { + $bconsole = '/usr/bin/bconsole' + } else { + $bconsole = '/usr/sbin/bconsole' + } + # Instead of restarting the bacula-dir service which could interrupt running jobs tell the director to reload its # configuration. exec { 'bacula-dir reload': - command => '/bin/echo reload | /usr/sbin/bconsole', + command => "/bin/echo reload | ${bconsole}", logoutput => on_failure, refreshonly => true, timeout => 10, diff --git a/manifests/director/mysql.pp b/manifests/director/mysql.pp index 220e5a7..05dce44 100644 --- a/manifests/director/mysql.pp +++ b/manifests/director/mysql.pp @@ -47,7 +47,12 @@ $db_require = Class['::mysql::server'] } } else { - $db_require = undef + if defined(Class['percona']) { + $db_require = Class['percona'] + $is_percona = true + } else { + $db_require = undef + } } $db_user_host_real = $db_user_host ? { @@ -55,20 +60,36 @@ default => $db_user_host, } - mysql::db { $db_database: - user => $db_user, - password => $db_password, - host => $db_user_host, - grant => ['all'], - require => $db_require, - notify => Exec['make_db_tables'], + if $is_percona { + percona::database { $db_database: + ensure => present, + notify => Exec['make_db_tables'], + } + + percona::rights { "${db_user}@${db_user_host}/${db_database}": + database => $db_database, + priv => [ 'all' ], + host => $db_user_host, + password => $db_password, + } + } else { + mysql::db { $db_database: + user => $db_user, + password => $db_password, + host => $db_user_host, + grant => ['all'], + require => $db_require, + notify => Exec['make_db_tables'], + } } } $make_db_tables_command = $::operatingsystem ? { - /(Ubuntu|Debian)/ => '/usr/lib/bacula/make_bacula_tables', - default => '/usr/libexec/bacula/make_mysql_tables', + Debian => '/usr/lib/bacula/make_bacula_tables', + Ubuntu => '/usr/share/bacula-director/make_mysql_tables', + default => '/usr/libexec/bacula/make_mysql_tables', } + $db_parameters = "--host=${db_host} --user=${db_user} --password=${db_password} --port=${db_port} --database=${db_database}" exec { 'make_db_tables': From 2c648a8ee8a0d98bee191e501e9b98207a6209f7 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Wed, 25 Feb 2015 19:28:10 +0300 Subject: [PATCH 2/9] Fix ubuntu support --- manifests/director.pp | 3 +++ manifests/params.pp | 12 ++++++++++++ manifests/params/validate.pp | 12 ++++++------ templates/bacula-dir.conf.erb | 6 +++--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/manifests/director.pp b/manifests/director.pp index fa51564..0a104f4 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -69,6 +69,9 @@ ) { include ::bacula::params + $scripts_dir = $::bacula::params::scripts_dir + $catalog_dir = $::bacula::params::catalog_dir + $director_server_real = $director_server ? { undef => $::bacula::params::director_server_default, default => $director_server, diff --git a/manifests/params.pp b/manifests/params.pp index 95eca92..5a4708c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -72,4 +72,16 @@ /(Debian|Ubuntu)/ => 'bacula-sd-sqlite', default => 'bacula-storage-sqlite', } + + case $::operatingsystem { + /(Ubuntu)/: { + $scripts_dir = '/etc/bacula/scripts' + $catalog_dir = '/var/lib/bacula' + } + default: { + $scripts_dir = '/usr/libexec/bacula' + $catalog_dir = '/var/spool/bacula' + } + } + } diff --git a/manifests/params/validate.pp b/manifests/params/validate.pp index 9578b8e..04d7e53 100644 --- a/manifests/params/validate.pp +++ b/manifests/params/validate.pp @@ -93,18 +93,18 @@ validate_re($volume_autoprune_incr, '^(Yes|yes|No|no)$') # Validate mail_to variables are email address - if $mail_to != undef { + if $mail_to != '' { validate_re($mail_to, '^[\w-]+@([\w-]+\.)+[\w-]+$') - } elsif $mail_to == undef and $mail_to_on_error == undef { + } elsif $mail_to == '' and $mail_to_on_error == '' { validate_re($::bacula::params::mail_to_default, '^[\w-]+@([\w-]+\.)+[\w-]+$') } - if $mail_to_daemon != undef { + if $mail_to_daemon != '' { validate_re($mail_to_daemon, '^[\w-]+@([\w-]+\.)+[\w-]+$') } - if $mail_to_on_error != undef { + if $mail_to_on_error != '' { validate_re($mail_to_on_error, '^[\w-]+@([\w-]+\.)+[\w-]+$') } - if $mail_to_operator != undef { + if $mail_to_operator != '' { validate_re($mail_to_operator, '^[\w-]+@([\w-]+\.)+[\w-]+$') } } @@ -168,7 +168,7 @@ validate_absolute_path($storage_default_mount) - if $plugin_dir != undef { + if $plugin_dir != '' { validate_absolute_path($plugin_dir) } diff --git a/templates/bacula-dir.conf.erb b/templates/bacula-dir.conf.erb index 7b81c31..53393cb 100644 --- a/templates/bacula-dir.conf.erb +++ b/templates/bacula-dir.conf.erb @@ -296,7 +296,7 @@ FileSet { Signature = SHA1 Compression = GZIP } - File = "/var/spool/bacula/bacula.sql" + File = "<%= @catalog_dir -%>/bacula.sql" } } @@ -391,9 +391,9 @@ Job { Messages = "<%= director_server_real -%>:messages:standard" Pool = "<%= storage_server_real -%>:pool:catalog" # This creates an ASCII copy of the catalog - RunBeforeJob = "/usr/libexec/bacula/make_catalog_backup.pl <%= director_server_real -%>:<%= db_backend -%>" + RunBeforeJob = "<%= @scripts_dir -%>/make_catalog_backup.pl <%= director_server_real -%>:<%= db_backend -%>" # This deletes the copy of the catalog - RunAfterJob = "/usr/libexec/bacula/delete_catalog_backup" + RunAfterJob = "<%= @scripts_dir -%>/delete_catalog_backup" Write Bootstrap = "/var/lib/bacula/BackupCatalog.bsr" # Run after main backup Priority = 50 From f42dd4640c56cb8ed19ac4892716be29a44dc9d3 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Wed, 25 Feb 2015 22:07:52 +0300 Subject: [PATCH 3/9] Add bconsole_cmd variable, simple fix --- manifests/director.pp | 9 ++++----- manifests/director/mysql.pp | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/manifests/director.pp b/manifests/director.pp index d739f70..5bf4448 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -238,16 +238,15 @@ require => $service_require, } - if $::osfamily == 'Debian' { - $bconsole = '/usr/bin/bconsole' - } else { - $bconsole = '/usr/sbin/bconsole' + $bconsole_cmd = $::osfamily ? { + 'Debian' => '/usr/bin/bconsole', + default => '/usr/sbin/bconsole', } # Instead of restarting the bacula-dir service which could interrupt running jobs tell the director to reload its # configuration. exec { 'bacula-dir reload': - command => "/bin/echo reload | ${bconsole}", + command => "/bin/echo reload | ${bconsole_cmd}", logoutput => on_failure, refreshonly => true, timeout => 10, diff --git a/manifests/director/mysql.pp b/manifests/director/mysql.pp index 05dce44..2c283d3 100644 --- a/manifests/director/mysql.pp +++ b/manifests/director/mysql.pp @@ -85,8 +85,8 @@ } $make_db_tables_command = $::operatingsystem ? { - Debian => '/usr/lib/bacula/make_bacula_tables', - Ubuntu => '/usr/share/bacula-director/make_mysql_tables', + 'Debian' => '/usr/lib/bacula/make_bacula_tables', + 'Ubuntu' => '/usr/share/bacula-director/make_mysql_tables', default => '/usr/libexec/bacula/make_mysql_tables', } From b28398ffbe11cbd942b086eeb2fac1d816b3d2bb Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Wed, 25 Feb 2015 22:10:05 +0300 Subject: [PATCH 4/9] puppet-lint fix --- manifests/director/mysql.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/director/mysql.pp b/manifests/director/mysql.pp index 2c283d3..c808f96 100644 --- a/manifests/director/mysql.pp +++ b/manifests/director/mysql.pp @@ -63,7 +63,7 @@ if $is_percona { percona::database { $db_database: ensure => present, - notify => Exec['make_db_tables'], + notify => Exec['make_db_tables'], } percona::rights { "${db_user}@${db_user_host}/${db_database}": From 4f80983684b39726bec5cd538277d713407ec275 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 28 Sep 2015 18:47:24 +0300 Subject: [PATCH 5/9] * fix fileset template * fix custom config path --- manifests/director/custom_config.pp | 5 +++-- templates/bacula-dir.conf.erb | 2 +- templates/fileset.conf.erb | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/manifests/director/custom_config.pp b/manifests/director/custom_config.pp index 41d0395..ef75b18 100644 --- a/manifests/director/custom_config.pp +++ b/manifests/director/custom_config.pp @@ -28,7 +28,8 @@ $ensure = 'file', $director_server = undef, $content = undef, - $source = undef + $source = undef, + $subdir = 'bacula-dir.d', ) { if !($ensure in ['file', 'absent']) { fail('The only valid values for the ensure parameter are file or absent') @@ -40,7 +41,7 @@ fail('You must supply either the content or source parameter') } - file { "/etc/bacula/bacula-dir.d/custom-${name}.conf": + file { "/etc/bacula/${subdir}/custom-${name}.conf": ensure => file, owner => 'bacula', group => 'bacula', diff --git a/templates/bacula-dir.conf.erb b/templates/bacula-dir.conf.erb index 736914d..27d0f9d 100644 --- a/templates/bacula-dir.conf.erb +++ b/templates/bacula-dir.conf.erb @@ -296,7 +296,7 @@ FileSet { Signature = SHA1 Compression = GZIP } - File = "/var/spool/bacula/bacula.sql" + File = "<%= @catalog_dir %>/bacula.sql" } } diff --git a/templates/fileset.conf.erb b/templates/fileset.conf.erb index bc13f3d..32be0f7 100644 --- a/templates/fileset.conf.erb +++ b/templates/fileset.conf.erb @@ -6,9 +6,14 @@ FileSet { Compression = GZIP } +<% if @include_files.kind_of? Array -%> <% include_files.each do |file_include| -%> File = <%= file_include %> <% end -%> +<% else -%> + File = <%= include_files %> +<% end -%> + } <% if @exclude_files -%> From 59610e7ee1068ac8f3d0c373f8e2d0905e71c1c6 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Fri, 10 Jun 2016 14:53:37 +0300 Subject: [PATCH 6/9] * add JobDefs options --- manifests/client/config.pp | 1 + templates/client_config.erb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/manifests/client/config.pp b/manifests/client/config.pp index 36b1a8a..23314c5 100644 --- a/manifests/client/config.pp +++ b/manifests/client/config.pp @@ -104,6 +104,7 @@ $ensure = file, $backup_enable = 'yes', $client_schedule = 'WeeklyCycle', + $jobdefs = undef, $db_backend = undef, $director_password = '', $director_server = undef, diff --git a/templates/client_config.erb b/templates/client_config.erb index 67e9552..cbcaf6c 100644 --- a/templates/client_config.erb +++ b/templates/client_config.erb @@ -23,6 +23,9 @@ Job { Client = "<%= @name %>" Type = Backup Enabled = "<%= @backup_enable %>" +<% if @jobdefs -%> + JobDefs = "DefaultJob" +<%- end -%> <%- if @priority -%> Priority = <%= @priority %> <%- end -%> From 999781e99cfae45bf62b1d8ad521e9bc255ab826 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 12 Nov 2018 13:29:32 +0300 Subject: [PATCH 7/9] * Add options volume_recycle, bootstrap, * Change pool format * Add parallel jobs --- manifests/client/config.pp | 3 ++- manifests/director.pp | 10 ++++++++++ manifests/init.pp | 3 +++ manifests/params/validate.pp | 1 + manifests/storage.pp | 2 +- templates/bacula-dir.conf.erb | 26 ++++++++++++++++---------- templates/bacula-fd.conf.erb | 2 +- templates/client_config.erb | 23 +++++++++++++++-------- 8 files changed, 49 insertions(+), 21 deletions(-) diff --git a/manifests/client/config.pp b/manifests/client/config.pp index 36b1a8a..70773f1 100644 --- a/manifests/client/config.pp +++ b/manifests/client/config.pp @@ -122,6 +122,7 @@ $tls_ca_cert_dir = undef, $tls_require = 'yes', $use_tls = false, + $bootstrap = "/var/lib/bacula/${name}.bsr", ) { include ::bacula::params @@ -193,7 +194,7 @@ } if $run_scripts { - case type($run_scripts) { + case type3x($run_scripts) { 'array' : { # TODO figure out how to validate each item in the array is a hash. $run_scripts_real = $run_scripts diff --git a/manifests/director.pp b/manifests/director.pp index 9349973..af9d374 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -62,6 +62,7 @@ $use_tls = false, $use_vol_purge_script = false, $use_vol_purge_mvdir = undef, + $volume_recycle = 'No', $volume_autoprune = 'Yes', $volume_autoprune_diff = 'Yes', $volume_autoprune_full = 'Yes', @@ -278,4 +279,13 @@ Service['bacula-dir'], ], } + + + concat { "/etc/bacula/bacula-dir.d/pools.conf": + owner => 'bacula', + group => 'tape', + mode => '0644', + } + + } diff --git a/manifests/init.pp b/manifests/init.pp index f3b6732..094ffc9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -240,6 +240,7 @@ $use_tls = false, $use_vol_purge_script = false, $use_vol_purge_mvdir = undef, + $volume_recycle = 'No', $volume_autoprune = 'Yes', $volume_autoprune_diff = 'Yes', $volume_autoprune_full = 'Yes', @@ -309,6 +310,7 @@ use_tls => $use_tls, use_vol_purge_script => $use_vol_purge_script, use_vol_purge_mvdir => $use_vol_purge_mvdir, + volume_recycle => $volume_recycle, volume_autoprune => $volume_autoprune, volume_autoprune_diff => $volume_autoprune_diff, volume_autoprune_full => $volume_autoprune_full, @@ -370,6 +372,7 @@ use_tls => $use_tls, use_vol_purge_script => $use_vol_purge_script, use_vol_purge_mvdir => $use_vol_purge_mvdir, + volume_recycle => $volume_recycle, volume_autoprune => $volume_autoprune, volume_autoprune_diff => $volume_autoprune_diff, volume_autoprune_full => $volume_autoprune_full, diff --git a/manifests/params/validate.pp b/manifests/params/validate.pp index 31317a8..4883a24 100644 --- a/manifests/params/validate.pp +++ b/manifests/params/validate.pp @@ -61,6 +61,7 @@ $use_tls = '', $use_vol_purge_script = false, $use_vol_purge_mvdir = undef, + $volume_recycle = '', $volume_autoprune = '', $volume_autoprune_diff = '', $volume_autoprune_full = '', diff --git a/manifests/storage.pp b/manifests/storage.pp index 1d101bc..8d5824a 100644 --- a/manifests/storage.pp +++ b/manifests/storage.pp @@ -84,7 +84,7 @@ ensure => directory, owner => 'bacula', group => 'bacula', - mode => '0755', + mode => '0770', require => Package[$db_package], } diff --git a/templates/bacula-dir.conf.erb b/templates/bacula-dir.conf.erb index 17a5ed8..c53e7ee 100644 --- a/templates/bacula-dir.conf.erb +++ b/templates/bacula-dir.conf.erb @@ -13,7 +13,7 @@ Director { <% if @plugin_dir -%> Plugin Directory = <%= @plugin_dir %> <% end -%> - Maximum Concurrent Jobs = 5 + Maximum Concurrent Jobs = 20 Password = "<%= @director_password -%>" Messages = "<%= @director_server_real -%>:messages:daemon" <% if @use_tls -%> @@ -95,6 +95,7 @@ Storage { Password = "<%= @director_password -%>" Device = "DefaultFileStorage" Media Type = File + Maximum Concurrent Jobs = 20 <% if @use_tls -%> TLS Enable = yes TLS Require = <%= @tls_require %> @@ -120,12 +121,13 @@ Pool { # theory the same time period for weekly backups from the clients) # Note the files for the old volumes will still remain on the disk but will # be truncated to a zero size. - Recycle = No + Recycle = <%= @volume_recycle %> Auto Prune = <%= @volume_autoprune %> Action On Purge = Truncate Volume Retention = <%= @volume_retention %> # Don't allow re-use of volumes; one volume per job only - Maximum Volume Jobs = 1 + Maximum Volume Bytes = 100G + Maximum Volume Jobs = 20 } Pool { Name = "<%= @storage_server_real -%>:pool:default.full" @@ -137,12 +139,13 @@ Pool { # Clean up any we don't need, and keep them for a maximum of a year # Note the files for the old volumes will still remain on the disk but will # be truncated to a zero size. - Recycle = No + Recycle = <%= @volume_recycle %> Auto Prune = <%= @volume_autoprune_full %> Action On Purge = Truncate Volume Retention = <%= @volume_retention_full %> # Don't allow re-use of volumes; one volume per job only - Maximum Volume Jobs = 1 + Maximum Volume Bytes = 100G + Maximum Volume Jobs = 20 } Pool { @@ -155,12 +158,13 @@ Pool { # Clean up any we don't need, and keep them for a maximum of fourty days # Note the files for the old volumes will still remain on the disk but will # be truncated to a zero size. - Recycle = No + Recycle = <%= @volume_recycle %> Auto Prune = <%= @volume_autoprune_diff %> Action On Purge = Truncate Volume Retention = <%= @volume_retention_diff %> # Don't allow re-use of volumes; one volume per job only - Maximum Volume Jobs = 1 + Maximum Volume Bytes = 100G + Maximum Volume Jobs = 20 } Pool { @@ -173,12 +177,13 @@ Pool { # Clean up any we don't need, and keep them for a maximum of 40 days # Note the files for the old volumes will still remain on the disk but will # be truncated to a zero size. - Recycle = No + Recycle = <%= @volume_recycle %> Auto Prune = <%= @volume_autoprune_incr %> Action On Purge = Truncate Volume Retention = <%= @volume_retention_incr %> # Don't allow re-use of volumes; one volume per job only - Maximum Volume Jobs = 1 + Maximum Volume Bytes = 100G + Maximum Volume Jobs = 20 } Pool { @@ -195,7 +200,7 @@ Pool { # we should keep at least one weeks worth of backups of the database Volume Retention = 1 Week # Don't allow re-use of volumes; one volume per job only - Maximum Volume Jobs = 1 + Maximum Volume Jobs = 20 } # Create a Counter which will be used to label the catalog volumes on the system @@ -395,6 +400,7 @@ Job { # This deletes the copy of the catalog RunAfterJob = "<%= @scripts_dir -%>/delete_catalog_backup" Write Bootstrap = "/var/lib/bacula/BackupCatalog.bsr" + Maximum Concurrent Jobs = 20 # Run after main backup Priority = 50 <% if @use_vol_purge_script -%> diff --git a/templates/bacula-fd.conf.erb b/templates/bacula-fd.conf.erb index 4114d0c..6afa8c5 100644 --- a/templates/bacula-fd.conf.erb +++ b/templates/bacula-fd.conf.erb @@ -36,7 +36,7 @@ FileDaemon { Plugin Directory = <%= @plugin_dir %> <% end -%> PID Directory = /var/run/bacula - Maximum Concurrent Jobs = 3 + Maximum Concurrent Jobs = 20 <% if @use_tls -%> TLS Enable = yes TLS Require = <%= @tls_require %> diff --git a/templates/client_config.erb b/templates/client_config.erb index 67e9552..d1b6f66 100644 --- a/templates/client_config.erb +++ b/templates/client_config.erb @@ -4,8 +4,9 @@ Client { Password = "<%= @director_password_real %>" Catalog = "<%= @director_server_real %>:<%= @db_backend_real %>" File Retention = 6 Weeks - Job Retention = 1 Year + Job Retention = 6 Weeks Auto Prune = Yes + Maximum Concurrent Jobs = 20 <% if @use_tls -%> TLS Enable = Yes TLS Require = <%= @tls_require %> @@ -27,20 +28,23 @@ Job { Priority = <%= @priority %> <%- end -%> FileSet = "<%= @fileset %>" - Storage = "<%= @storage_server_real %>:storage:<%= @pool %>" + Storage = "<%= @storage_server_real %>:storage:default" Schedule = "<%= @client_schedule %>" - Pool = "<%= @storage_server_real %>:pool:<%= @pool %>" + Pool = "<%= @pool %>" <%- if @pool_full_real -%> - Full Backup Pool = "<%= @storage_server_real %>:pool:<%= @pool_full_real %>" + Full Backup Pool = "<%= @pool_full_real %>" <%- end -%> <%- if @pool_incr_real -%> - Incremental Backup Pool = "<%= @storage_server_real %>:pool:<%= @pool_incr_real %>" + Incremental Backup Pool = "<%= @pool_incr_real %>" <%- end -%> <%- if @pool_diff_real -%> - Differential Backup Pool = "<%= @storage_server_real %>:pool:<%= @pool_diff_real %>" + Differential Backup Pool = "<%= @pool_diff_real %>" <%- end -%> Messages = "<%= @director_server_real %>:messages:standard" Rerun Failed Levels = <%= @rerun_failed_levels %> + <%- if @bootstrap -%> + Write Bootstrap = "<%= @bootstrap %>" + <%- end -%> <% if @run_scripts_real -%> <%- @run_scripts_real.each do |runscript| -%> RunScript { @@ -74,8 +78,11 @@ Job { Type = Restore Enabled = "<%= @restore_enable %>" FileSet = "<%= @fileset %>" - Storage = "<%= @storage_server_real %>:storage:<%= @pool %>" - Pool = "<%= @storage_server_real %>:pool:<%= @pool %>" + Storage = "<%= @storage_server_real %>:storage:default" + Pool = "<%= @pool %>" Messages = "<%= @director_server_real %>:messages:standard" Where = <%= @restore_where %> + <%- if @bootstrap -%> + Bootstrap = "<%= @bootstrap %>" + <%- end -%> } From f7593e1f9dc7f832f817f62a083b38779f9976ad Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 12 Nov 2018 13:47:12 +0300 Subject: [PATCH 8/9] * add define bacula::client::job * add define bacula::director::pool --- manifests/client/job.pp | 32 +++++++++++++++++++ manifests/director/pool.pp | 40 ++++++++++++++++++++++++ templates/job.erb | 63 ++++++++++++++++++++++++++++++++++++++ templates/pool.erb | 17 ++++++++++ 4 files changed, 152 insertions(+) create mode 100644 manifests/client/job.pp create mode 100644 manifests/director/pool.pp create mode 100644 templates/job.erb create mode 100644 templates/pool.erb diff --git a/manifests/client/job.pp b/manifests/client/job.pp new file mode 100644 index 0000000..53ce489 --- /dev/null +++ b/manifests/client/job.pp @@ -0,0 +1,32 @@ +define bacula::client::job ( + $client = $name, + $type = Backup, + $backup_enable = 'yes', + $restore_enable = 'yes', + $storage_server_real = undef, + $client_schedule = undef, + $director_password = '', + $director_server_real = undef, + $fileset = 'Basic:noHome', + $run_scripts_real = undef, + $storage_server = undef, + $pool = 'default', + $rerun_failed_levels = undef, + $restore_where = '/var/tmp/bacula-restores', + $volume_autoprune = 'Yes', + $volume_retention = '1 Year', + $restore_where = undef, + $bootstrap = undef, +) { + + file { "/etc/bacula/bacula-dir.d/jobs-${name}.conf": + ensure => file, + owner => 'bacula', + group => 'bacula', + mode => '0640', + content => template('bacula/job.erb'), + notify => Exec['bacula-dir reload'], + } + +} + diff --git a/manifests/director/pool.pp b/manifests/director/pool.pp new file mode 100644 index 0000000..fe6d828 --- /dev/null +++ b/manifests/director/pool.pp @@ -0,0 +1,40 @@ +# == Define: bacula::director::pool +# +# Include a pool configuration file in /etc/bacula/bacula-dir.d/pools.conf. +# +# === Parameters +# +# === Examples +# +# Provide some examples on how to use this type: +# +# bacula::director::pool { 'namevar' : +# label_ext => full, +# } +# +define bacula::director::pool ( + $pool_type = 'Backup', + $label_format = '${Client}.${Year}${Month:p/2/0/r}${Day:p/2/0/r}.${Hour:p/2/0/r}${Minute:p/2/0/r}', + $label_ext = undef, + $recycle = 'Yes', + $auto_prune = 'Yes', + $volume_retention = '1 Week', + $max_volume_bytes = '100G', + $max_volume_jobs = 20, + $subdir = 'bacula-dir.d', +) { + if $label_ext == '' { + $fin_label_format = "${label_format}" + } else { + $fin_label_format = "${label_format}.${label_ext}" + } + + concat::fragment { "${name}": + ensure => present, + target => "/etc/bacula/${subdir}/pools.conf", + content => template('bacula/pool.erb'), + } + + + +} diff --git a/templates/job.erb b/templates/job.erb new file mode 100644 index 0000000..dcba00f --- /dev/null +++ b/templates/job.erb @@ -0,0 +1,63 @@ +Job { + Name = "<%= @name %>" + Client = "<%= @client %>" + Type = <%= @type %> + Enabled = "<%= @backup_enable %>" +<%- if @priority -%> + Priority = <%= @priority %> +<%- end -%> + FileSet = "<%= @fileset %>" + Storage = "<%= @storage_server_real %>:storage:<%= @pool %>" +<%- if @client_schedule -%> + Schedule = "<%= @client_schedule %>" +<%- end -%> + Pool = "<%= @storage_server_real %>:pool:<%= @pool %>" + <%- if @pool_full_real -%> + Full Backup Pool = "<%= @storage_server_real %>:pool:<%= @pool_full_real %>" + <%- end -%> + <%- if @pool_incr_real -%> + Incremental Backup Pool = "<%= @storage_server_real %>:pool:<%= @pool_incr_real %>" + <%- end -%> + <%- if @pool_diff_real -%> + Differential Backup Pool = "<%= @storage_server_real %>:pool:<%= @pool_diff_real %>" + <%- end -%> + Messages = "<%= @director_server_real %>:messages:standard" +<% if @rerun_failed_levels -%> + Rerun Failed Levels = <%= @rerun_failed_levels %> +<% end -%> +<% if @bootstrap -%> +<% if @type == "Backup" -%> + Write Bootstrap = "<%= @bootstrap %>" +<% else -%> +Bootstrap = "<%= @bootstrap %>" +<% end -%> +<% end -%> +<% if @restore_where -%> + Where = <%= @restore_where %> +<% end -%> +<% if @run_scripts_real -%> + <%- @run_scripts_real.each do |runscript| -%> + RunScript { + RunsWhen = <%= runscript['RunsWhen'] %> + <%- if runscript['RunsOnSuccess'] -%> + RunsOnSuccess = <%= runscript['RunsOnSuccess'] %> + <%- end -%> + <%- if runscript['RunsOnFailure'] -%> + RunsOnFailure = <%= runscript['RunsOnFailure'] %> + <%- end -%> + <%- if runscript['RunsOnClient'] -%> + RunsOnClient = <%= runscript['RunsOnClient'] %> + <%- end -%> + <%- if runscript['FailJobOnError'] -%> + FailJobOnError = <%= runscript['FailJobOnError'] %> + <%- end -%> + <%- if runscript['Command'] -%> + Command = "<%= runscript['Command'] %>" + <%- end -%> + <%- if runscript['Console'] -%> + Console = "<%= runscript['Console'] %>" + <%- end -%> + } + <%- end -%> +<% end -%> +} diff --git a/templates/pool.erb b/templates/pool.erb new file mode 100644 index 0000000..0696e0e --- /dev/null +++ b/templates/pool.erb @@ -0,0 +1,17 @@ +Pool { + Name = "<%= @name %>" + # All Volumes will have the format director.catalog.date.time to ensure they + # are kept unique throughout the operation and also aid quick analysis + Label Format = "<%= @fin_label_format%>" + Pool Type = <%= @pool_type %> + # Clean up any we don't need, and keep them for a maximum of a month (in + # theory the same time period for weekly backups from the clients) + Recycle = <%= @recycle %> + Auto Prune = <%= @auto_prune %> + # We have no limit on the number of volumes, but we will simply set that + # we should keep at least one weeks worth of backups of the database + Volume Retention = <%= @volume_retention %> + Maximum Volume Bytes = <%= @max_volume_bytes %> + Maximum Volume Jobs = <%= @max_volume_jobs %> +} + From 37319a710a1f31183ca4700f4184eca5e93cd68f Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 12 Nov 2018 14:00:16 +0300 Subject: [PATCH 9/9] * fix default value plugin_dir --- manifests/init.pp | 2 +- manifests/params.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 094ffc9..29c35bc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -225,7 +225,7 @@ $manage_db_tables = true, $manage_logwatch = undef, $operator_command = $::bacula::params::operator_command, - $plugin_dir = undef, + $plugin_dir = $::bacula::params::plugin_dir, $storage_default_mount = '/mnt/bacula', $storage_server = undef, $storage_template = undef, diff --git a/manifests/params.pp b/manifests/params.pp index 79cc544..f8969c8 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -49,7 +49,7 @@ x86_64 => 'lib64', default => 'lib', } - $libdir = $::operatingsystem ? { + $libdir = $facts['os']['family'] ? { /(Debian|Ubuntu)/ => '/usr/lib', default => "/usr/${lib}", }