Add pruning hooks
This commit is contained in:
parent
fb6608bf47
commit
0a7fdcb232
11
sanoid
11
sanoid
|
@ -299,6 +299,17 @@ sub prune_snapshots {
|
||||||
if (! $args{'readonly'}) {
|
if (! $args{'readonly'}) {
|
||||||
if (system($zfs, "destroy", $snap) == 0) {
|
if (system($zfs, "destroy", $snap) == 0) {
|
||||||
$pruned{$snap} = 1;
|
$pruned{$snap} = 1;
|
||||||
|
my $dataset = (split '@', $snap)[0];
|
||||||
|
my $snapname = (split '@', $snap)[1];
|
||||||
|
if ($config{$dataset}{'pruning_script'}) {
|
||||||
|
$ENV{'SANOID_TARGET'} = $dataset;
|
||||||
|
$ENV{'SANOID_SNAPNAME'} = $snapname;
|
||||||
|
if ($args{'verbose'}) { print "executing pruning_script '".$config{$dataset}{'pruning_script'}."' on dataset '$dataset'\n"; }
|
||||||
|
system($config{$dataset}{'pruning_script'}) == 0
|
||||||
|
or warn "WARN: pruning_script failed, $?";
|
||||||
|
delete $ENV{'SANOID_TARGET'};
|
||||||
|
delete $ENV{'SANOID_SNAPNAME'};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warn "could not remove $snap : $?";
|
warn "could not remove $snap : $?";
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@
|
||||||
#no_inconsistent_snapshot = yes
|
#no_inconsistent_snapshot = yes
|
||||||
### run post_snapshot_script when pre_snapshot_script is failing
|
### run post_snapshot_script when pre_snapshot_script is failing
|
||||||
#force_post_snapshot_script = yes
|
#force_post_snapshot_script = yes
|
||||||
|
### dataset name will be supplied as an environment variable $SANOID_TARGET
|
||||||
|
pruning_script = /path/to/script.sh
|
||||||
|
|
||||||
[template_ignore]
|
[template_ignore]
|
||||||
autoprune = no
|
autoprune = no
|
||||||
|
|
|
@ -19,6 +19,7 @@ pre_snapshot_script =
|
||||||
post_snapshot_script =
|
post_snapshot_script =
|
||||||
no_inconsistent_snapshot =
|
no_inconsistent_snapshot =
|
||||||
force_post_snapshot_script =
|
force_post_snapshot_script =
|
||||||
|
pruning_script =
|
||||||
|
|
||||||
# If any snapshot type is set to 0, we will not take snapshots for it - and will immediately
|
# If any snapshot type is set to 0, we will not take snapshots for it - and will immediately
|
||||||
# prune any of those type snapshots already present.
|
# prune any of those type snapshots already present.
|
||||||
|
|
Loading…
Reference in New Issue