CLIMATE-1151: added config option to use zfs recursion

This commit is contained in:
Sam Allred 2017-12-19 15:47:40 -07:00 committed by Christoph Klaffl
parent a7cb1e2226
commit 1605a60c62
No known key found for this signature in database
GPG Key ID: FC1C525C2A47CC28
1 changed files with 13 additions and 3 deletions

16
sanoid
View File

@ -502,7 +502,14 @@ sub take_snapshots {
# update to most current possible datestamp
%datestamp = get_date();
# print "we should have had a $type snapshot of $path $maxage seconds ago; most recent is $newestage seconds old.\n";
push(@newsnaps, "$path\@autosnap_$datestamp{'sortable'}${dateSuffix}_$type");
# use zfs recursion if specified in config
if ($config{$section}{'zfs_recursion'}) {
push(@newsnaps, "-r $path\@autosnap_$datestamp{'sortable'}_$type");
}else{
push(@newsnaps, "$path\@autosnap_$datestamp{'sortable'}_$type");
}
}
}
}
@ -530,7 +537,7 @@ sub take_snapshots {
}
if ($args{'verbose'}) { print "taking snapshot $snap\n"; }
if (!$args{'readonly'}) {
system($zfs, "snapshot", "$snap") == 0
system("$zfs snapshot $snap") == 0
or warn "CRITICAL ERROR: $zfs snapshot $snap failed, $?";
}
if ($config{$dataset}{'post_snapshot_script'} and !$args{'readonly'}) {
@ -846,7 +853,10 @@ sub init {
my $recursive = $ini{$section}{'recursive'} && grep( /^$ini{$section}{'recursive'}$/, @istrue );
my $skipChildren = $ini{$section}{'skip_children'} && grep( /^$ini{$section}{'skip_children'}$/, @istrue );
my @datasets;
if ($recursive || $skipChildren) {
if($ini{$section}{'recursive'} =~ /zfs/i) {
$config{$section}{'zfs_recursion'} = 1;
}elsif ($ini{$section}{'recursive'}) {
@datasets = getchilddatasets($config{$section}{'path'});
DATASETS: foreach my $dataset(@datasets) {
chomp $dataset;