mirror of https://github.com/jimsalterjrs/sanoid
Merge pull request #163 from phreaker0/weekly
implemented weekly period
This commit is contained in:
commit
61115712e8
26
sanoid
26
sanoid
|
|
@ -128,7 +128,7 @@ sub monitor_snapshots {
|
|||
my $path = $config{$section}{'path'};
|
||||
push @paths, $path;
|
||||
|
||||
my @types = ('yearly','monthly','daily','hourly','frequently');
|
||||
my @types = ('yearly','monthly','weekly','daily','hourly','frequently');
|
||||
foreach my $type (@types) {
|
||||
if ($config{$section}{$type} == 0) { next; }
|
||||
|
||||
|
|
@ -137,8 +137,9 @@ sub monitor_snapshots {
|
|||
if ($type eq 'frequently') { $smallerperiod = 1; }
|
||||
elsif ($type eq 'hourly') { $smallerperiod = 60; }
|
||||
elsif ($type eq 'daily') { $smallerperiod = 60*60; }
|
||||
elsif ($type eq 'monthly') { $smallerperiod = 60*60*24; }
|
||||
elsif ($type eq 'yearly') { $smallerperiod = 60*60*24; }
|
||||
elsif ($type eq 'weekly') { $smallerperiod = 60*60*24; }
|
||||
elsif ($type eq 'monthly') { $smallerperiod = 60*60*24*7; }
|
||||
elsif ($type eq 'yearly') { $smallerperiod = 60*60*24*31; }
|
||||
|
||||
my $typewarn = $type . '_warn';
|
||||
my $typecrit = $type . '_crit';
|
||||
|
|
@ -271,6 +272,7 @@ sub prune_snapshots {
|
|||
if ($type eq 'frequently') { $period = 60 * $config{$section}{'frequent_period'}; }
|
||||
elsif ($type eq 'hourly') { $period = 60*60; }
|
||||
elsif ($type eq 'daily') { $period = 60*60*24; }
|
||||
elsif ($type eq 'weekly') { $period = 60*60*24*7; }
|
||||
elsif ($type eq 'monthly') { $period = 60*60*24*31; }
|
||||
elsif ($type eq 'yearly') { $period = 60*60*24*365.25; }
|
||||
|
||||
|
|
@ -452,6 +454,24 @@ sub take_snapshots {
|
|||
$lastpreferred -= 2*$dstOffset;
|
||||
}
|
||||
} # preferred time is later today - so look at yesterday's
|
||||
} elsif ($type eq 'weekly') {
|
||||
# calculate offset in seconds for the desired weekday
|
||||
my $offset = 0;
|
||||
if ($config{$section}{'weekly_wday'} < $datestamp{'wday'}) {
|
||||
$offset += 7;
|
||||
}
|
||||
$offset += $config{$section}{'weekly_wday'} - $datestamp{'wday'};
|
||||
$offset *= 60*60*24; # full day
|
||||
|
||||
push @preferredtime,0; # try to hit 0 seconds
|
||||
push @preferredtime,$config{$section}{'weekly_min'};
|
||||
push @preferredtime,$config{$section}{'weekly_hour'};
|
||||
push @preferredtime,$datestamp{'mday'};
|
||||
push @preferredtime,($datestamp{'mon'}-1); # january is month 0
|
||||
push @preferredtime,$datestamp{'year'};
|
||||
$lastpreferred = timelocal(@preferredtime);
|
||||
$lastpreferred += $offset;
|
||||
if ($lastpreferred > time()) { $lastpreferred -= 60*60*24*7; } # preferred time is later this week - so look at last week's
|
||||
} elsif ($type eq 'monthly') {
|
||||
push @preferredtime,0; # try to hit 0 seconds
|
||||
push @preferredtime,$config{$section}{'monthly_min'};
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ autoprune = yes
|
|||
frequently = 0
|
||||
hourly = 48
|
||||
daily = 90
|
||||
weekly = 0
|
||||
monthly = 6
|
||||
yearly = 0
|
||||
# pruning can be skipped based on the used capacity of the pool
|
||||
|
|
@ -65,6 +66,10 @@ hourly_min = 0
|
|||
# daily - at 23:59 (most people expect a daily to contain everything done DURING that day)
|
||||
daily_hour = 23
|
||||
daily_min = 59
|
||||
# weekly -at 23:30 each Monday
|
||||
weekly_wday = 1
|
||||
weekly_hour = 23
|
||||
weekly_min = 30
|
||||
# monthly - immediately at the beginning of the month (ie 00:00 of day 1)
|
||||
monthly_mday = 1
|
||||
monthly_hour = 0
|
||||
|
|
@ -93,8 +98,10 @@ hourly_warn = 90
|
|||
hourly_crit = 360
|
||||
daily_warn = 28
|
||||
daily_crit = 32
|
||||
monthly_warn = 32
|
||||
monthly_crit = 35
|
||||
weekly_warn = 0
|
||||
weekly_crit = 0
|
||||
monthly_warn = 5
|
||||
monthly_crit = 6
|
||||
yearly_warn = 0
|
||||
yearly_crit = 0
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue