Merge with maxdelorme/master
diff --git a/manifests/client.pp b/manifests/client.pp
index 80a3738..b988b7f 100644
--- a/manifests/client.pp
+++ b/manifests/client.pp
@@ -12,6 +12,13 @@
# [*ensure*]
# Present or absent.
#
+# [*client_name_alias*]
+# Override the client's host name. This allows multiple clients to all refer to the same physical host. This should only be set in the per-PC config file and is only used by BackupPC at the last moment prior to generating the command used to backup that machine (ie: the value of $Conf{ClientNameAlias} is invisible everywhere else in BackupPC). The setting can be a host name or IP address, eg:
+# $Conf{ClientNameAlias} = 'realHostName';
+# $Conf{ClientNameAlias} = '192.1.1.15';
+# will cause the relevant smb/tar/rsync backup/restore commands to be directed to realHostName, not the client name.
+# Note: this setting doesn't work for hosts with DHCP set to 1.
+#
# [*system_account*]
# Name of the user that will be created to allow backuppc
# access to the system via ssh. This only applies to xfer
@@ -53,10 +60,29 @@
# PC is not on the network, a number of consecutive bad pings is allowed
# before the good ping count is reset.
#
+# [*blackout_periods*]
+# One or more blackout periods can be specified. If a client is subject to blackout then no regular (non-manual) backups will be started during any of these periods. hourBegin and hourEnd specify hours fro midnight and weekDays is a list of days of the week where 0 is Sunday, 1 is Monday etc.
+# For example:
+# $Conf{BlackoutPeriods} = [
+# {
+# hourBegin => 7.0,
+# hourEnd => 19.5,
+# weekDays => [1, 2, 3, 4, 5],
+# },
+# ];
+# specifies one blackout period from 7:00am to 7:30pm local time on Mon-Fri.
+#
# [*ping_max_msec*]
# Maximum latency between backuppc server and client to schedule
# a backup. Default to 20ms.
#
+# [*ping_cmd*]
+# Ping command. The following variables are substituted at run-time:
+# $pingPath path to ping ($Conf{PingPath})
+# $host host name
+# Wade Brown reports that on solaris 2.6 and 2.7 ping -s returns the wrong exit status (0 even on failure). Replace with "ping $host 1", which gets the correct exit status but we don't get the round-trip time.
+# Note: all Cmds are executed directly without a shell, so the prog name needs to be a full path and you can't include shell syntax like redirection and pipes; put that in a script if you need it.
+#
# [*backups_disable*]
# Disable all full and incremental backups. These settings are useful for a client that
# is no longer being backed up (eg: a retired machine), but you wish to keep the last backups
@@ -196,6 +222,7 @@
class backuppc::client (
$ensure = 'present',
$backuppc_hostname = '',
+ $client_name_alias = false,
$system_account = 'backup',
$system_home_directory = '/var/backups',
$system_additional_commands = [],
@@ -213,7 +240,9 @@
$partial_age_max = false,
$blackout_bad_ping_limit = false,
$ping_max_msec = false,
+ $ping_cmd = false,
$blackout_good_cnt = false,
+ $blackout_periods = false,
$backups_disable = false,
$xfer_method = 'rsync',
$xfer_loglevel = '1',
@@ -265,7 +294,9 @@
validate_re($xfer_method, '^(smb|rsync|rsyncd|tar)$',
'Xfer_method parameter must have value of: smb, rsync, rsyncd or tar')
-
+ if $blackout_periods != false {
+ validate_array($blackout_periods)
+ }
validate_re($xfer_loglevel, '^[0-2]$',
'Xfer_loglevel parameter must be a 0, 1 or 2')
diff --git a/manifests/server.pp b/manifests/server.pp
index f01b5d1..575c1ad 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -22,6 +22,32 @@
# there are no user backup requests then this is the
# maximum number of simultaneous backups.
#
+#[*cgi_admin_user_group*]
+#[*cgi_admin_users*]
+#The administrative users are the union of the unix/linux
+#group $Conf{CgiAdminUserGroup} and the manual list of users,
+#separated by spaces, in $Conf{CgiAdminUsers}.
+#If you don't want a group or manual list of users set the
+#corresponding configuration setting to undef or an empty string.
+#
+#[*language*]
+#
+#Language to use. See lib/BackupPC/Lang for the list of
+#supported languages, which include English (en), French (fr),
+#Spanish (es), German (de), Italian (it), Dutch (nl), Polish (pl),
+#Portuguese Brazillian (pt_br) and Chinese (zh_CH).
+# cz, de, en, es, fr, it, nl, pl, pt_br, zh_CN
+#
+#Currently the Language setting applies to the CGI interface and email
+#messages sent to users. Log files and other text are still in English.
+# [*cgi_url*]
+# URL of the BackupPC_Admin CGI script. Used for email messages.
+#
+# [*cgi_image_dir_url*]
+# URL (without the leading http://host) for BackupPC's image directory. The CGI script uses this value to serve up image files.
+# Example:
+# $Conf{CgiImageDirURL} = '/BackupPC';
+#
# [*max_user_backups*]
# Additional number of simultaneous backups that users
# can run. As many as $Conf{MaxBackups} + $Conf{MaxUserBackups}
@@ -160,6 +186,12 @@
# [*backuppc_password*]
# Password for the backuppc user used to access the web interface.
#
+# [*user_cmd_check_status*]
+# boolean
+# Whether the exit status of each PreUserCmd and PostUserCmd is checked.
+# If set and the Dump/Restore/Archive Pre/Post UserCmd returns a non-zero exit status then the dump/restore/archive is aborted. To maintain backward compatibility (where the exit status in early versions was always ignored), this flag defaults to 0.
+# If this flag is set and the Dump/Restore/Archive PreUserCmd fails then the matching Dump/Restore/Archive PostUserCmd is not executed. If DumpPreShareCmd returns a non-exit status, then DumpPostShareCmd is not executed, but the DumpPostUserCmd is still run (since DumpPreUserCmd must have previously succeeded).
+# An example of a DumpPreUserCmd that might fail is a script that snapshots or dumps a database which fails because of some database error.
# [*topdir*]
# Overwrite package default location for backuppc.
#
@@ -177,6 +209,7 @@
$wakeup_schedule = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
$max_backups = 4,
$max_user_backups = 4,
+ $language = 'en',
$max_pending_cmds = 15,
$max_backup_pc_nightly_jobs = 2,
$backup_pc_nightly_period = 1,
@@ -185,7 +218,7 @@
$trash_clean_sleep_sec = 300,
$dhcp_address_ranges = [],
$full_period = '6.97',
- $full_keep_cnt = 1,
+ $full_keep_cnt = [1],
$full_age_max = 90,
$incr_period = '0.97',
$incr_keep_cnt = 6,
@@ -196,6 +229,7 @@
$restore_info_keep_cnt = 10,
$archive_info_keep_cnt = 10,
$blackout_good_cnt = 7,
+ $cgi_url = '"http://".$Conf{ServerHost}."/backuppc/index.cgi"',
$blackout_periods = [ { hourBegin => 7.0,
hourEnd => 19.5,
weekDays => [1, 2, 3, 4, 5],
@@ -211,9 +245,12 @@
$apache_allow_from = 'all',
$apache_require_ssl = false,
$backuppc_password = '',
- $topdir = '',
-) {
- include backuppc::params
+ $topdir = $backuppc::params::topdir,
+ $cgi_image_dir_url = $backuppc::params::cgi_image_dir_url,
+ $cgi_admin_users = 'backuppc',
+ $cgi_admin_user_group = 'backuppc',
+ $user_cmd_check_status = true,
+) inherits backuppc::params {
if empty($backuppc_password) {
fail('Please provide a password for the backuppc user. This is used to login to the web based administration site.')
@@ -254,9 +291,6 @@
validate_re("${incr_period}", '^[0-9]([0-9]*)?(\.[0-9]{1,2})?$',
'Incr_period parameter should be a number')
- validate_re("${full_keep_cnt}", '^[1-9]([0-9]*)?$',
- 'Full_keep_cnt parameter should be a number')
-
validate_re("${full_age_max}", '^[1-9]([0-9]*)?$',
'Full_age_max parameter should be a number')
@@ -288,13 +322,20 @@
validate_array($dhcp_address_ranges)
validate_array($incr_levels)
validate_array($blackout_periods)
+ validate_array($full_keep_cnt)
validate_hash($email_headers)
validate_string($apache_allow_from)
+ validate_string($cgi_url)
+ validate_string($cgi_image_dir_url)
+ validate_string($language)
+ validate_string($cgi_admin_user_group)
+ validate_string($cgi_admin_users)
$real_incr_fill = bool2num($incr_fill)
$real_bzfif = bool2num($blackout_zero_files_is_fatal)
+ $real_uccs = bool2num($user_cmd_check_status)
$real_topdir = $topdir ? {
'' => $backuppc::params::topdir,
@@ -320,7 +361,7 @@
service { $backuppc::params::service:
ensure => $service_enable,
enable => $service_enable,
- hasstatus => false,
+ hasstatus => true,
pattern => 'BackupPC'
}
@@ -328,8 +369,9 @@
ensure => $ensure,
owner => 'backuppc',
group => $backuppc::params::group_apache,
- mode => '0644',
+ mode => '0640',
content => template('backuppc/config.pl.erb'),
+ notify => Service[$backuppc::params::service]
}
file { $backuppc::params::config_directory:
@@ -347,10 +389,11 @@
file { [$real_topdir, "${real_topdir}/.ssh"]:
ensure => 'directory',
- recurse => true,
owner => 'backuppc',
group => $backuppc::params::group_apache,
- mode => '0644',
+ mode => '0640',
+ require => Package[$backuppc::params::package],
+ ignore => 'BackupPC.sock',
}
# Workaround for client exported resources that are
diff --git a/templates/config.pl.erb b/templates/config.pl.erb
index ba137af..454b24b 100644
--- a/templates/config.pl.erb
+++ b/templates/config.pl.erb
@@ -194,7 +194,7 @@
$Conf{RestorePostUserCmd} = undef;
$Conf{ArchivePreUserCmd} = undef;
$Conf{ArchivePostUserCmd} = undef;
-$Conf{UserCmdCheckStatus} = 1;
+$Conf{UserCmdCheckStatus} = <% if @real_uccs -%>'<%= @real_uccs %>'<% end %>,;
$Conf{ClientNameAlias} = undef;
$Conf{SendmailPath} = '/usr/sbin/sendmail';
$Conf{EMailNotifyMinDays} = <%= @email_notify_min_days %>;
@@ -215,9 +215,9 @@
<% end -%>
EOF
$Conf{CgiAdminUserGroup} = 'backuppc';
-$Conf{CgiAdminUsers} = 'backuppc';
-$Conf{CgiURL} = 'http://'.$Conf{ServerHost}.'/backuppc/index.cgi';
-$Conf{Language} = 'en';
+$Conf{CgiAdminUsers} = '<%= @cgi_admin_users %>';
+$Conf{CgiURL} = '<%= @cgi_url %>';
+$Conf{Language} = '<%= @language %>';
$Conf{CgiUserHomePageCheck} = '';
$Conf{CgiUserUrlCreate} = 'mailto:%s';
$Conf{CgiDateFormatMMDD} = 1;
@@ -243,13 +243,13 @@
Reason_no_ping => '#ffff99',
Reason_backup_canceled_by_user => '#ff9900',
Status_backup_in_progress => '#66cc99',
- Disabled_OnlyManualBackups => '#d1d1d1',
- Disabled_AllBackupsDisabled => '#d1d1d1',
+ Disabled_OnlyManualBackups => '#d1d1d1',
+ Disabled_AllBackupsDisabled => '#d1d1d1',
};
$Conf{CgiHeaders} = '<meta http-equiv="pragma" content="no-cache">';
$Conf{CgiImageDir} = '<%= scope.lookupvar('backuppc::params::cgi_image_dir') %>';
$Conf{CgiExt2ContentType} = { };
-$Conf{CgiImageDirURL} = '<%= scope.lookupvar('backuppc::params::cgi_image_dir_url') %>';
+$Conf{CgiImageDirURL} = '<%= @cgi_image_dir_url %>';
$Conf{CgiCSSFile} = 'BackupPC_stnd.css';
$Conf{CgiUserConfigEditEnable} = 1;
$Conf{CgiUserConfigEdit} = {
diff --git a/templates/host.pl.erb b/templates/host.pl.erb
index 796b0a5..e5912c1 100644
--- a/templates/host.pl.erb
+++ b/templates/host.pl.erb
@@ -1,3 +1,6 @@
+<% if @client_name_alias -%>
+$Conf{ClientNameAlias} = '<%= @client_name_alias%>';
+<% end -%>
$Conf{XferMethod} = '<%= @xfer_method %>';
$Conf{XferLogLevel} = <%= @xfer_loglevel %>;
<% if @backups_disable -%>
@@ -33,6 +36,9 @@
<% if @blackout_bad_ping_limit -%>
$Conf{BlackoutBadPingLimit} = <%= @blackout_bad_ping_limit %>;
<% end -%>
+<% if @ping_cmd -%>
+$Conf{PingCmd} = '<%= @ping_cmd %>';
+<% end -%>
<% if @ping_max_msec -%>
$Conf{PingMaxMsec} = <%= @ping_max_msec %>;
<% end -%>
@@ -181,3 +187,14 @@
<% if @email_notify_old_backup_days -%>
$Conf{EMailNotifyOldBackupDays} = <%= @email_notify_old_backup_days %>;
<% end -%>
+<% if @blackout_periods -%>
+$Conf{BlackoutPeriods} = [
+<% @blackout_periods.each do |period| -%>
+<% if period.is_a?(Hash) -%>{
+<% period.each_pair do |key,value| -%>
+ <%= key %> => <% if value.is_a?(Array) %>[<%= value.join(', ') %>]<% else %><%= value %><% end %>,
+<% end -%>
+},
+<% end -%>
+<% end -%>];
+<% end -%>