Skip to content

Commit eb1ddb1

Browse files
committed
Skip crontab creation when retain value is set to zero
1 parent 0fd079c commit eb1ddb1

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

manifests/server/config.pp

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,45 @@
8383
# cronjobs
8484

8585
## hourly
86-
cron { "rsnapshot-${name}-hourly" :
87-
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} hourly",
88-
user => $server_user,
89-
hour => $backup_hourly_cron,
90-
minute => $backup_time_minute
91-
} ->
86+
if ($retain_hourly > 0) {
87+
cron { "rsnapshot-${name}-hourly" :
88+
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} hourly",
89+
user => $server_user,
90+
hour => $backup_hourly_cron,
91+
minute => $backup_time_minute
92+
}
93+
}
9294

9395
## daily
94-
cron { "rsnapshot-${name}-daily" :
95-
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} daily",
96-
user => $server_user,
97-
hour => $backup_time_hour,
98-
minute => ($backup_time_minute + 50) % 60
99-
} ->
96+
if ($retain_daily > 0) {
97+
cron { "rsnapshot-${name}-daily" :
98+
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} daily",
99+
user => $server_user,
100+
hour => $backup_time_hour,
101+
minute => ($backup_time_minute + 50) % 60
102+
}
103+
}
100104

101105
## weekly
102-
cron { "rsnapshot-${name}-weekly" :
103-
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} weekly",
104-
user => $server_user,
105-
hour => ($backup_time_hour + 3) % 24,
106-
minute => ($backup_time_minute + 50) % 60,
107-
weekday => $backup_time_weekday
108-
} ->
106+
if ($retain_weekly > 0) {
107+
cron { "rsnapshot-${name}-weekly" :
108+
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} weekly",
109+
user => $server_user,
110+
hour => ($backup_time_hour + 3) % 24,
111+
minute => ($backup_time_minute + 50) % 60,
112+
weekday => $backup_time_weekday
113+
}
114+
}
109115

110116
## monthly
111-
cron { "rsnapshot-${name}-monthly" :
112-
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} monthly",
113-
user => $server_user,
114-
hour => ($backup_time_hour + 7) % 24,
115-
minute => ($backup_time_minute + 50) % 60,
116-
monthday => $backup_time_dom
117+
if ($retain_monthly > 0) {
118+
cron { "rsnapshot-${name}-monthly" :
119+
command => "${rsnapshot::server::cmd_rsnapshot} -c ${config_file} monthly",
120+
user => $server_user,
121+
hour => ($backup_time_hour + 7) % 24,
122+
minute => ($backup_time_minute + 50) % 60,
123+
monthday => $backup_time_dom
124+
}
117125
}
118126

119127
$programs = {

0 commit comments

Comments
 (0)