mirror of
https://github.com/krislamo/puppet-rsnapshot
synced 2024-11-10 00:00:35 +00:00
add prefix feature
This commit is contained in:
parent
960b0090e4
commit
87775af5c7
@ -2,8 +2,8 @@
|
||||
#
|
||||
# manage host configs
|
||||
class rsnapshot::config (
|
||||
$hosts = $rsnapshot::hosts,
|
||||
$cron_dir = $rsnapshot::cron_dir,
|
||||
$hosts = $rsnapshot::hosts,
|
||||
$cron_dir = $rsnapshot::cron_dir,
|
||||
) {
|
||||
|
||||
# these are global settings, no point in setting them per host
|
||||
@ -12,6 +12,8 @@ class rsnapshot::config (
|
||||
$conf_d = pick($rsnapshot::conf_d, $rsnapshot::params::conf_d, '/etc/rsnapshot')
|
||||
$snapshot_root = pick($hosts['snapshot_root'], $rsnapshot::snapshot_root, '/backup')
|
||||
$logpath = pick($rsnapshot::logpath, $rsnapshot::params::config_logpath)
|
||||
$cronfile_prefix_use = pick($rsnapshot::cronfile_prefix_use, $rsnapshot::params::cronfile_prefix_use, false)
|
||||
$cronfile_prefix = pick($rsnapshot::cronfile_prefix, $rsnapshot::params::cronfile_prefix, '')
|
||||
# make sure lock path and conf path exist
|
||||
file { $conf_d:
|
||||
ensure => 'directory',
|
||||
@ -162,23 +164,25 @@ class rsnapshot::config (
|
||||
}
|
||||
}
|
||||
|
||||
if rsnapshot_prefix_use == false {
|
||||
$rsnapshot_prefix = ''
|
||||
if $cronfile_prefix_use {
|
||||
$rsnapshot_prefix = $rsnapshot::cronfile_prefix
|
||||
} else {
|
||||
$rsnapshot_prefix = ''
|
||||
}
|
||||
|
||||
# cron on Debian seems to ignore files that have dots in their name; replace
|
||||
# them with underscores (issue #2)
|
||||
if $::osfamily == 'Debian' {
|
||||
$cron_name = regsubst($host, '\.', '_', 'G')
|
||||
$cronfile = "${cron_dir}/${rsnapshot_prefix}${cron_name}"
|
||||
}
|
||||
else {
|
||||
$cronfile = "${cron_dir}/${rsnapshot_prefix}${host}"
|
||||
}
|
||||
|
||||
# Make sure old cron files without rsnapshot_prefix are removed
|
||||
file { "${cron_dir}/${host}":
|
||||
ensure => absent,
|
||||
case $::osfamily {
|
||||
'Debian': {
|
||||
$cron_name = regsubst($host, '\.', '_', 'G')
|
||||
$cronfile = "${cron_dir}/${rsnapshot_prefix}${cron_name}"
|
||||
}
|
||||
'RedHat': {
|
||||
$cronfile = "${cron_dir}/${rsnapshot_prefix}${host}"
|
||||
}
|
||||
default: {
|
||||
$cronfile = "${cron_dir}/${rsnapshot_prefix}${host}"
|
||||
}
|
||||
}
|
||||
|
||||
concat { $cronfile:
|
||||
|
@ -19,8 +19,8 @@ class rsnapshot (
|
||||
$snapshot_root = $rsnapshot::params::config_snapshot_root,
|
||||
$backup_levels = $rsnapshot::params::config_backup_levels,
|
||||
$cron_service_name = $rsnapshot::params::cron_service_name,
|
||||
$rsnapshot_prefix = $rsnapshot::params::config_rsnapshot_prefix,
|
||||
$rsnapshot_prefix_use = $rsnapshot::params::config_rsnapshot_prefix_use,
|
||||
$cronfile_prefix = $rsnapshot::params::config_cronfile_prefix,
|
||||
$cronfile_prefix_use = $rsnapshot::params::config_cronfile_prefix_use,
|
||||
$check_mk_job = $rsnapshot::params::config_check_mk_job,
|
||||
|
||||
) inherits rsnapshot::params {
|
||||
|
@ -43,8 +43,8 @@ class rsnapshot::params {
|
||||
$config_verbose = '2'
|
||||
$config_loglevel = '4'
|
||||
$config_stop_on_stale_lockfile = undef # bool
|
||||
$config_rsnapshot_prefix = 'rsnapshot_'
|
||||
$config_rsnapshot_prefix_use = false
|
||||
$config_cronfile_prefix = 'rsnapshot_'
|
||||
$config_cronfile_prefix_use = false
|
||||
$config_rsync_short_args = '-az'
|
||||
$config_rsync_long_args = undef # defaults are --delete --numeric-ids --relative --delete-excluded
|
||||
$config_ssh_args = undef
|
||||
@ -127,6 +127,6 @@ class rsnapshot::params {
|
||||
],
|
||||
default => [],
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user