1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
class rsnapshot {
class base($confdir = '/backups/conf') {
package { ['rsnapshot']: }
file { $confdir:
ensure => directory,
owner => root,
group => root,
mode => 0700,
}
@rsnapshot::cron_file { 'hourly': }
@rsnapshot::cron_file { 'daily': }
@rsnapshot::cron_file { 'weekly': }
@rsnapshot::cron_file { 'monthly': }
}
define cron_file($rsnapshot_conf = []) {
$filepath = "/tmp/cron.${name}_rsnapshot-backups"
$rsnapshot_arg = $name
file { $filepath:
ensure => present,
content => template('rsnapshot/cron_file'),
owner => root,
group => root,
mode => 0755,
}
}
# - 'backup' is an array of "source destination" to backup
# - 'backup_script' is an array of "script destination"
# - ${x}_interval is the number of hourly, daily, weekly, monthly
# backups that should be kept. If you don't want hourly, daily,
# weekly or monthly backups, set ${x}_interval to '0'
define backup(
$snapshot_root = '/backups',
$one_fs = '1',
$backup = [],
$backup_script = [],
$hourly_interval = '0',
$daily_interval = '6',
$weekly_interval = '4',
$monthly_interval = '3'
) {
$conffile = "${rsnapshot::base::confdir}/${name}.conf"
file { $conffile:
owner => root,
group => root,
mode => 0700,
content => template('rsnapshot/rsnapshot.conf'),
}
if ($hourly_interval != '0') {
Rsnapshot::Cron_file <| title == 'hourly' |> {
rsnapshot_conf +> $conffile,
}
}
if ($daily_interval != '0') {
Rsnapshot::Cron_file <| title == 'daily' |> {
rsnapshot_conf +> $conffile,
}
}
if ($weekly_interval != '0') {
Rsnapshot::Cron_file <| title == 'weekly' |> {
rsnapshot_conf +> $conffile,
}
}
if ($monthly_interval != '0') {
Rsnapshot::Cron_file <| title == 'monthly' |> {
rsnapshot_conf +> $conffile,
}
}
}
}
|