This commit is contained in:
Björn 2025-11-09 22:51:57 +01:00 committed by GitHub
commit 9354ce8c78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 36 additions and 2 deletions

36
sanoid
View File

@ -144,6 +144,33 @@ if ($args{'cron'}) {
exit 0;
####################################################################################
####################################################################################
####################################################################################
sub get_active_datasets {
my ($config, $snaps, $snapsbytype, $snapsbypath) = @_;
#my %datestamp = get_date();
#my $errlevel = 0;
#my $msg;
#my @msgs;
my @paths;
foreach my $section (keys %config) {
if ($section =~ /^template/) { next; }
if (! $config{$section}{'autoprune'}) { next; }
if (! $config{$section}{'autosnap'}) { next; }
if ($config{$section}{'process_children_only'}) { next; }
my $path = $config{$section}{'path'};
push @paths, $path;
}
my @sorted_paths = sort { lc($a) cmp lc($b) } @paths;
my $paths = join (" ", @sorted_paths);
return $paths
}
####################################################################################
####################################################################################
####################################################################################
@ -883,10 +910,17 @@ sub getsnaps {
print "INFO: cache expired - updating from zfs list.\n";
}
}
# just get snapshots from configured datasets to not spin up the disks
open FH, "$zfs get -Hrpt snapshot creation ".get_active_datasets(@params)." |";
@rawsnaps = <FH>;
close FH;
$exit_code = $? >> 8;
if ($exit_code != 0) {
print "INFO: zfs list shapshots with dataset names does not work.. retrying without dataset names (this will spin-up all disks)\n";
open FH, "$zfs get -Hrpt snapshot creation |";
@rawsnaps = <FH>;
close FH;
}
open FH, "> $cache.tmp" or die "Could not write to $cache.tmp!\n";
print FH @rawsnaps;
close FH;