mirror of
https://github.com/krislamo/puppet-rsnapshot
synced 2024-11-10 00:00:35 +00:00
allow to override default cron time ranges
This commit is contained in:
parent
a63e9e47da
commit
cafb00e201
@ -16,12 +16,6 @@ class rsnapshot::config (
|
|||||||
ensure => 'directory',
|
ensure => 'directory',
|
||||||
}
|
}
|
||||||
|
|
||||||
# $foo='*/5'
|
|
||||||
#$qax = rand_from_array($foo)
|
|
||||||
#notice("QAX is $qax ")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# custom function, if only a hostname is given as a param, this is an empty hash
|
# custom function, if only a hostname is given as a param, this is an empty hash
|
||||||
# the next loop would break as puppet does not allow to reassign variables
|
# the next loop would break as puppet does not allow to reassign variables
|
||||||
@ -121,20 +115,30 @@ class rsnapshot::config (
|
|||||||
#15 1 * * 0 /usr/bin/rsnapshot -c /etc/rsnapshot/cmweb1.rsnapshot.conf weekly
|
#15 1 * * 0 /usr/bin/rsnapshot -c /etc/rsnapshot/cmweb1.rsnapshot.conf weekly
|
||||||
# 00 1 1 * * /usr/bin/rsnapshot -c /etc/rsnapshot/cmweb1.rsnapshot.conf monthly
|
# 00 1 1 * * /usr/bin/rsnapshot -c /etc/rsnapshot/cmweb1.rsnapshot.conf monthly
|
||||||
$cronfile = "/tmp/rsnapshot.d/cron/${host}"
|
$cronfile = "/tmp/rsnapshot.d/cron/${host}"
|
||||||
$cron = pick_default($hash['cron'], $rsnapshot::params::cron, 'absent')
|
|
||||||
|
|
||||||
concat { "${cronfile}":
|
concat { "${cronfile}":
|
||||||
# replace => false,
|
# replace => false,
|
||||||
}
|
}
|
||||||
|
# $cron = pick($hash['cron'], $rsnapshot::params::cron)
|
||||||
|
|
||||||
|
|
||||||
|
# notify { "cron is ${cron} ": }
|
||||||
$backup_levels.each |String $level| {
|
$backup_levels.each |String $level| {
|
||||||
# allow to globally override ranges, create random numbers for backup_levels daily, weekly, monthly
|
if validate_hash($hash) {
|
||||||
$c_min = pick($cron['minute'], $rsnapshot::params::cron['minute'], '*')
|
# allow to globally override ranges, create random numbers for backup_levels daily, weekly, monthly
|
||||||
$c_hour = pick($cron['hour'], $rsnapshot::params::cron['hour'], '*')
|
if has_key($host, 'cron'){
|
||||||
$c_monthday = pick($cron['monthday'], $rsnapshot::params::cron['monthday'], '*')
|
$c_min = pick($host['cron'][$level]['minute'], $rsnapshot::params::cron[$level]['minute'], '*')
|
||||||
$c_month = pick($cron['month'], $rsnapshot::params::cron['month'], '*')
|
$c_hour = pick($host['cron'][$level]['hour'], $rsnapshot::params::cron[$level]['hour'], '*')
|
||||||
$c_weekday = pick($cron['weekday'], $rsnapshot::params::cron['weekday'], '*')
|
$c_monthday = pick($host['cron'][$level]['monthday'], $rsnapshot::params::cron[$level]['monthday'], '*')
|
||||||
|
$c_month = pick($host['cron'][$level]['month'], $rsnapshot::params::cron[$level]['month'], '*')
|
||||||
|
$c_weekday = pick($host['cron'][$level]['weekday'], $rsnapshot::params::cron[$level]['weekday'], '*')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$c_min = $rsnapshot::params::cron[$level]['minute']
|
||||||
|
$c_hour = $rsnapshot::params::cron[$level]['hour']
|
||||||
|
$c_monthday = $rsnapshot::params::cron[$level]['monthday']
|
||||||
|
$c_month = $rsnapshot::params::cron[$level]['month']
|
||||||
|
$c_weekday = $rsnapshot::params::cron[$level]['weekday']
|
||||||
|
}
|
||||||
$minute = rand_from_array($c_min, "${host}.${level}")
|
$minute = rand_from_array($c_min, "${host}.${level}")
|
||||||
$hour = rand_from_array($c_hour, "${host}.${level}")
|
$hour = rand_from_array($c_hour, "${host}.${level}")
|
||||||
$monthday = rand_from_array($c_monthday, "${host}.${level}")
|
$monthday = rand_from_array($c_monthday, "${host}.${level}")
|
||||||
|
@ -61,11 +61,41 @@ class rsnapshot::params {
|
|||||||
}
|
}
|
||||||
$config_backup_scripts = {}
|
$config_backup_scripts = {}
|
||||||
|
|
||||||
$cron = {
|
# $cron = {
|
||||||
'minute' => '0..59',
|
# 'minute' => '0..59',
|
||||||
'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
|
# 'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
|
||||||
'monthday' => '0..28',
|
# 'monthday' => '0..28',
|
||||||
'month' => '1..12',
|
# 'month' => '1..12',
|
||||||
'weekday' => '0..6',
|
# 'weekday' => '0..6',
|
||||||
|
# }
|
||||||
|
$cron = {
|
||||||
|
'hourly' => {
|
||||||
|
'minute' => '0..59',
|
||||||
|
'hour' => '*', # you could also do: ['21..23','0..4','5'],
|
||||||
|
'monthday' => '*',
|
||||||
|
'month' => '*',
|
||||||
|
'weekday' => '*',
|
||||||
|
},
|
||||||
|
'daily' => {
|
||||||
|
'minute' => '0..59',
|
||||||
|
'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
|
||||||
|
'monthday' => '*',
|
||||||
|
'month' => '*',
|
||||||
|
'weekday' => '*',
|
||||||
|
},
|
||||||
|
'weekly' => {
|
||||||
|
'minute' => '0..59',
|
||||||
|
'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
|
||||||
|
'monthday' => '*',
|
||||||
|
'month' => '*',
|
||||||
|
'weekday' => '0..6',
|
||||||
|
},
|
||||||
|
'monthly' => {
|
||||||
|
'minute' => '0..59',
|
||||||
|
'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
|
||||||
|
'monthday' => '0..28',
|
||||||
|
'month' => '*',
|
||||||
|
'weekday' => '*',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
<%= @minute %> <%= @hour %> <%= @monthday %> <%= @weekday %> root /usr/bin/rsnapshot -c <%= @config %> <%= @level %>
|
<%= @minute %> <%= @hour %> <%= @month %> <%= @monthday %> <%= @weekday %> root /usr/bin/rsnapshot -c <%= @config %> <%= @level %>
|
||||||
|
Loading…
Reference in New Issue
Block a user