Skip to content

Commit bf21b6f

Browse files
authored
Merge pull request #8 from rudybroersma/master
Please look at my first ever pull request :)
2 parents 388cbcc + 3b2d455 commit bf21b6f

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ This class has two required parameters- the backup `server`, which should be an
169169
fqdn, and an array of `directories` to back up. Additional options, such as
170170
retain rules or cronjob times, can be overridden as needed.
171171

172+
When the retain values are set to zero, no cron entry for that specific
173+
period is created.
174+
172175
```puppet
173176
class { 'rsnapshot::client':
174177
server => 'backups.example.com',
@@ -481,4 +484,4 @@ an rsnapshot server to backup clients that are not controlled by puppet.
481484
## Development
482485

483486
Contributions are always welcome. Please read the [Contributing Guide](CONTRIBUTING.md)
484-
to get started.
487+
to get started.

manifests/server/config.pp

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
$rsync_wrapper_processed = "--rsync-path=\"${wrapper_path_norm}/${wrapper_rsync_ssh}\""
6868
}
6969

70-
$rsync_long_args_final = "${ssh_args_processed} ${rsync_long_args} ${rsync_wrapper_processed}"
70+
$rsync_long_args_final = "${ssh_args_processed} ${rsync_long_args} ${rsync_wrapper_processed}".strip
7171

7272

7373
file { $snapshot_root :
@@ -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 = {

templates/config.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ exclude <%= value %>
101101
###############################
102102

103103
<% @directories.each do |source_dir| -%>
104-
backup <%= @client_user %>@<%= @name %>:<%= source_dir.gsub(/\/$/, '') %>/<%= "\t" %>
104+
backup <%= @client_user %>@<%= @name %>:<%= source_dir.gsub(/\/$/, '') %>/<%= "\t" %><%= "\t\t." %>
105105
<% end -%>

0 commit comments

Comments
 (0)