1
0
mirror of https://github.com/krislamo/puppet-rsnapshot synced 2024-12-16 09:40:35 +00:00

fail if backup_defaults is false and no backups specified for a host (user error)

This commit is contained in:
Norbert Varzariu 2015-12-19 22:49:34 +01:00
parent 53ead018cb
commit ac28d614de
4 changed files with 14 additions and 5 deletions

View File

@ -25,7 +25,8 @@ class rsnapshot::config (
$hosts_clean.each |String $host, Hash $hash | {
$snapshot_root = pick($hash['snapshot_root'], $rsnapshot::params::config_snapshot_root)
$backup_user = pick($hash['backup_user'], $rsnapshot::params::config_backup_user)
$backup = pick($hash['backup'], $rsnapshot::params::config_backup)
$default_backup_dirs = pick($rsnapshot::default_backup, $rsnapshot::params::config_default_backup)
$backup = $hash['backup']
$backup_defaults = pick($hash['backup_defaults'], $rsnapshot::params::config_backup_defaults)
$cmd_cp = pick($hash['cmd_cp'], $rsnapshot::params::config_cmd_cp)
$cmd_rm = pick($hash['cmd_rm'], $rsnapshot::params::config_cmd_rm)
@ -72,9 +73,14 @@ class rsnapshot::config (
$lockfile = "${lockpath}/${host}.pid"
$logfile = "${logpath}/${host}.log"
# fail if $backup_defaults is set to false and no $host[backup] defined
if ! $backup_defaults and ! $backup {
fail("There is no point in not specifying a backup, I got backup_defaults: ${backup_defaults} and backup definitions for this host (${host}) don't exist")
}
# merge the backup hashes to one if backup_default is set (defaults to true)
if $backup_defaults {
$backups = merge($backup, $rsnapshot::params::config_backup)
$backups = merge($backup, $default_backup_dirs)
} else {
$backups = $backup
}

View File

@ -9,6 +9,7 @@ class rsnapshot (
$conf_d = $rsnapshot::params::conf_d,
$logpath = $rsnapshot::params::config_logpath,
$lockpath = $rsnapshot::params::config_lockpath,
$default_backup = $rsnapshot::params::config_default_backup,
) inherits rsnapshot::params {
# anchor { 'rsnapshot::begin': } ->

View File

@ -54,7 +54,7 @@ class rsnapshot::params {
$config_sync_first = false
$config_rsync_numtries = 1
$config_use_lazy_deletes = false
$config_backup = {
$config_default_backup = {
'/etc' => './',
'/home' => './',
}

View File

@ -128,7 +128,9 @@ linux_lvm_mountpath <%= @linux_lvm_mountpath %>
<% end -%>
<% end -%>
<% @backups.each_pair do |source, dest| -%>
<% if @backup_user != '' -%>
<% if @host == 'localhost' -%>
backup <%= source %> <%=dest%>
<% elsif @backup_user != '' -%>
backup <%= @backup_user %>@<%=@host%>:<%= source %> <%=dest%>
<% else -%>
backup <%=@host%>:<%= source %> <%=dest%>