From 510becee2f5c35e23c53d42d19fee2856c9b0682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Tue, 17 Jun 2025 13:32:59 +0200 Subject: [PATCH 1/3] get snpshots from list of datasets query the existing snapshots only from the configured datasets to avoud spinning up disks that are not in the config --- sanoid | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sanoid b/sanoid index 4a71319..aae3b5f 100755 --- a/sanoid +++ b/sanoid @@ -883,7 +883,8 @@ sub getsnaps { print "INFO: cache expired - updating from zfs list.\n"; } } - open FH, "$zfs get -Hrpt snapshot creation |"; + # just get snapshots from configured datasets to not spin up the disks + open FH, "$zfs get -Hrpt snapshot creation ".join(" ",keys %$config)." |"; @rawsnaps = ; close FH; From 24b0293b0fc4079498512dae80964600350dc3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Mon, 25 Aug 2025 17:52:48 +0200 Subject: [PATCH 2/3] fallback to old zfs list snapshot method in case of error --- sanoid | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sanoid b/sanoid index aae3b5f..895ede3 100755 --- a/sanoid +++ b/sanoid @@ -887,7 +887,13 @@ sub getsnaps { open FH, "$zfs get -Hrpt snapshot creation ".join(" ",keys %$config)." |"; @rawsnaps = ; 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 = ; + close FH; + } open FH, "> $cache.tmp" or die "Could not write to $cache.tmp!\n"; print FH @rawsnaps; close FH; From 1c6d7d6459831d408a44ec27f5120500ebb592dd Mon Sep 17 00:00:00 2001 From: Bjoern Riemer Date: Sun, 9 Nov 2025 22:44:20 +0100 Subject: [PATCH 3/3] onl query not ignored datasets for snapshots --- sanoid | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sanoid b/sanoid index 895ede3..c052e1c 100755 --- a/sanoid +++ b/sanoid @@ -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 +} + #################################################################################### #################################################################################### #################################################################################### @@ -884,7 +911,7 @@ sub getsnaps { } } # just get snapshots from configured datasets to not spin up the disks - open FH, "$zfs get -Hrpt snapshot creation ".join(" ",keys %$config)." |"; + open FH, "$zfs get -Hrpt snapshot creation ".get_active_datasets(@params)." |"; @rawsnaps = ; close FH; $exit_code = $? >> 8;