summaryrefslogtreecommitdiffstats
path: root/draksnapshot-config
diff options
context:
space:
mode:
Diffstat (limited to 'draksnapshot-config')
-rwxr-xr-xdraksnapshot-config45
1 files changed, 18 insertions, 27 deletions
diff --git a/draksnapshot-config b/draksnapshot-config
index 3eaf7d8..5b93fc3 100755
--- a/draksnapshot-config
+++ b/draksnapshot-config
@@ -301,35 +301,26 @@ sub save_keyword {
sub generate_cron_entry() {
- my %minutes = (
- 'hourly' => 0,
- 'daily' => 50,
- 'weekly' => 40,
- 'monthly' => 30,
- );
+ # handle upgrading from old scheme to new scheme:
+ unlink("$::prefix/etc/cron.d/rsnapshot");
- my $cron_file = "$::prefix/etc/cron.d/rsnapshot";
+ my $cron_file = "$::prefix/etc/cron.\%s/rsnapshot";
- output_with_perm($cron_file, 0644,
- qq(# WARNING: This file is autogenerated from /etc/rsnapshot.conf.
+ my @current_conf = cat_($config_file);
+
+ foreach my $type (qw(hourly daily weekly monthly)) {
+ my $current_setting = grep { /^interval\s$type/ } @current_conf;
+ if (my ($interval) = $current_setting = ~ /^interval\s*$type\s*(\S*)/) {
+ my $file = sprintf($cron_file, $type);
+ output_with_perm($file, 0755,
+ qq(# WARNING: This file is autogenerated from /etc/rsnapshot.conf.
# WARNING: Please alter /etc/rsnapshot.conf instead of $cron_file
+# Then rerun draksnapshot-config
#
-# $cron_file: crontab fragment for rsnapshot
-
-),
- (map {
- if (my ($type, $interval) = /^interval\s*(\S*)\s*(\S*)/) {
- # crontab: minute hour day_month month day_of_week user command
- join("\t",
- $minutes{$type},
- ($type eq 'hourly' ? "*/" . 24/$interval : 4),
- ($type eq 'monthly' ? 1 : '*'),
- '*' ,
- ($type eq 'weekly' ? 6 : '*'),
- 'root',
- "/usr/bin/rsnapshot $type"
- ), "\n";
- }
- } grep { /^interval\s/ } cat_($config_file)),
- );
+# $file: crontab fragment for rsnapshot
+
+/usr/bin/rsnapshot $type
+));
+ }
+ }
}