diff --git a/README.md b/README.md index 5f50e63..fab9dcd 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,7 @@ Boolean. Backup default backup dirs or not. ####`$cron` Hash. Set time ranges for different backup levels. Hash is of the form: +```puppet cron =>{ daily => { minute => param, @@ -216,6 +217,26 @@ cron =>{ } {...} } +``` +####`$snapshot_root` +global. the directory holding your backups. you will end up with a structure like: +``` +/backup/ +├── example.com +│   ├── daily.0 +│   ├── daily.1 +│   ├── daily.2 +│   ├── daily.3 +│   ├── weekly.0 +│   ├── weekly.1 +│   ├── weekly.2 +│   └── weekly.3 +└── localhost + ├── daily.0 + ├── daily.1 + ├── daily.2 + └── weekly.0 +``` ### rsnapshot configuration variables Please read up on the following in the [rsnapshot manpage](http://linux.die.net/man/1/rsnapshot) ####`$cmd_cp` @@ -239,7 +260,6 @@ Please read up on the following in the [rsnapshot manpage](http://linux.die.net/ ####`$logpath` ####`$logfile` ####`$lockpath` -####`$snapshot_root` ####`$no_create_root` ####`$verbose` ####`$loglevel` diff --git a/manifests/config.pp b/manifests/config.pp index 1b39c1d..ab4af20 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -9,6 +9,7 @@ class rsnapshot::config ( $config_version = $rsnapshot::params::config_version $lockpath = pick($rsnapshot::lockpath, $rsnapshot::params::config_lockpath) $conf_d = pick($rsnapshot::conf_d, $rsnapshot::params::conf_d) + $snapshot_root = pick($hosts['snapshot_root'], $rsnapshot::params::config_snapshot_root) # make sure lock path and conf path exist file { $conf_d: ensure => 'directory', @@ -19,6 +20,9 @@ class rsnapshot::config ( file { $cron_dir: ensure => 'directory', } + file { $snapshot_root: + ensure => 'directory', + } # 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 function checks $hosts for elements like: @@ -26,7 +30,6 @@ class rsnapshot::config ( $hosts_clean = assert_empty_hash($hosts) $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) $default_backup_dirs = pick($rsnapshot::default_backup, $rsnapshot::params::config_default_backup) $backup_levels = pick($hash['backup_levels'], $rsnapshot::params::config_backup_levels, 'weekly') @@ -105,13 +108,12 @@ class rsnapshot::config ( } file { $exclude_file: - ensure => file, + ensure => 'file', } file { $config: content => template('rsnapshot/rsnapshot.erb') } - - $cronfile = "/tmp/rsnapshot.d/cron/${host}" + $cronfile = "${cron_dir}/${host}" concat { "${cronfile}": } $backup_levels.each |String $level| { diff --git a/manifests/params.pp b/manifests/params.pp index 5ddccf0..d4cd5c4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,11 +3,11 @@ # default params class rsnapshot::params { $hosts = undef - $conf_d = '/tmp/rsnapshot.d' # the place where the host specific configs are stored - $config_backup_user = 'root' + $conf_d = '/etc/rsnapshot' # the place where the host specific configs are stored + $config_backup_user = 'root' $package_name = 'rsnapshot' $package_ensure = 'present' - $cron_dir = '/tmp/rsnapshot.d/cron' + $cron_dir = '/etc/cron.d' $config_backup_levels = [ 'daily', 'weekly', ] $config_backup_defaults = true $config_version = '1.2'