Restructure to pass hashes around in take_snapshots
This commit makes it easier to pass structured data between the loop which decides what to snapshot, and the loop performing the actual snapshot.
This commit is contained in:
parent
1f616e74cc
commit
6252cbf514
49
sanoid
49
sanoid
|
@ -503,47 +503,30 @@ sub take_snapshots {
|
||||||
# update to most current possible datestamp
|
# update to most current possible datestamp
|
||||||
%datestamp = get_date();
|
%datestamp = get_date();
|
||||||
# print "we should have had a $type snapshot of $path $maxage seconds ago; most recent is $newestage seconds old.\n";
|
# print "we should have had a $type snapshot of $path $maxage seconds ago; most recent is $newestage seconds old.\n";
|
||||||
|
my $snap = {
|
||||||
my $flags = "";
|
'dataset' => $path,
|
||||||
# use zfs (atomic) recursion if specified in config
|
'snapshot' => "autosnap_$datestamp{'sortable'}_$type",
|
||||||
if ($config{$section}{'zfs_recursion'}) {
|
'recursive' => $config{$section}{'zfs_recrsion'}, # use zfs (atomic) recursion if specified in config
|
||||||
$flags .= "r";
|
'handleDst' => $handleDst,
|
||||||
}
|
};
|
||||||
if ($handleDst) {
|
push(@newsnaps, $snap);
|
||||||
$flags .= "d";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($flags ne "") {
|
|
||||||
push(@newsnaps, "$path\@autosnap_$datestamp{'sortable'}_$type\@$flags");
|
|
||||||
} else {
|
|
||||||
push(@newsnaps, "$path\@autosnap_$datestamp{'sortable'}_$type");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (scalar(@newsnaps)) > 0) {
|
if ( (scalar(@newsnaps)) > 0) {
|
||||||
foreach my $snap ( @newsnaps ) {
|
foreach my $snapData ( @newsnaps ) {
|
||||||
|
my $dataset = $snapData->{dataset};
|
||||||
|
my $snapname = $snapData->{snapshot};
|
||||||
|
my $recursiveFlag = $snapData->{recursive};
|
||||||
|
my $dstHandling = $snapData->{handleDst};
|
||||||
my $extraMessage = "";
|
my $extraMessage = "";
|
||||||
my @split = split '@', $snap, -1;
|
if ($recursiveFlag) {
|
||||||
my $recursiveFlag = 0;
|
$extraMessage = " (zfs recursive)";
|
||||||
my $dstHandling = 0;
|
|
||||||
if (scalar(@split) == 3) {
|
|
||||||
my $flags = $split[2];
|
|
||||||
if (index($flags, "r") != -1) {
|
|
||||||
$recursiveFlag = 1;
|
|
||||||
$extraMessage = " (zfs recursive)";
|
|
||||||
chop $snap;
|
|
||||||
}
|
|
||||||
if (index($flags, "d") != -1) {
|
|
||||||
$dstHandling = 1;
|
|
||||||
chop $snap;
|
|
||||||
}
|
|
||||||
chop $snap;
|
|
||||||
}
|
}
|
||||||
my $dataset = $split[0];
|
my $snap = "$dataset\@$snapname";
|
||||||
my $snapname = $split[1];
|
|
||||||
my $presnapshotfailure = 0;
|
my $presnapshotfailure = 0;
|
||||||
my $ret = 0;
|
my $ret = 0;
|
||||||
if ($config{$dataset}{'pre_snapshot_script'}) {
|
if ($config{$dataset}{'pre_snapshot_script'}) {
|
||||||
|
|
Loading…
Reference in New Issue