mirror of
https://github.com/jimsalterjrs/sanoid.git
synced 2024-09-10 10:52:45 +02:00
pre/post snapshot script calls should be also dumped in --readonly mode
This commit is contained in:
parent
a7cb1e2226
commit
7cf64be702
1 changed files with 11 additions and 4 deletions
13
sanoid
13
sanoid
|
@ -513,11 +513,15 @@ sub take_snapshots {
|
||||||
my $dataset = (split '@', $snap)[0];
|
my $dataset = (split '@', $snap)[0];
|
||||||
my $snapname = (split '@', $snap)[1];
|
my $snapname = (split '@', $snap)[1];
|
||||||
my $presnapshotfailure = 0;
|
my $presnapshotfailure = 0;
|
||||||
if ($config{$dataset}{'pre_snapshot_script'} and !$args{'readonly'}) {
|
my $ret = 0;
|
||||||
|
if ($config{$dataset}{'pre_snapshot_script'}) {
|
||||||
$ENV{'SANOID_TARGET'} = $dataset;
|
$ENV{'SANOID_TARGET'} = $dataset;
|
||||||
$ENV{'SANOID_SNAPNAME'} = $snapname;
|
$ENV{'SANOID_SNAPNAME'} = $snapname;
|
||||||
if ($args{'verbose'}) { print "executing pre_snapshot_script '".$config{$dataset}{'pre_snapshot_script'}."' on dataset '$dataset'\n"; }
|
if ($args{'verbose'}) { print "executing pre_snapshot_script '".$config{$dataset}{'pre_snapshot_script'}."' on dataset '$dataset'\n"; }
|
||||||
my $ret = runscript('pre_snapshot_script',$dataset);
|
|
||||||
|
if (!$args{'readonly'}) {
|
||||||
|
$ret = runscript('pre_snapshot_script',$dataset);
|
||||||
|
}
|
||||||
|
|
||||||
delete $ENV{'SANOID_TARGET'};
|
delete $ENV{'SANOID_TARGET'};
|
||||||
delete $ENV{'SANOID_SNAPNAME'};
|
delete $ENV{'SANOID_SNAPNAME'};
|
||||||
|
@ -533,12 +537,15 @@ sub take_snapshots {
|
||||||
system($zfs, "snapshot", "$snap") == 0
|
system($zfs, "snapshot", "$snap") == 0
|
||||||
or warn "CRITICAL ERROR: $zfs snapshot $snap failed, $?";
|
or warn "CRITICAL ERROR: $zfs snapshot $snap failed, $?";
|
||||||
}
|
}
|
||||||
if ($config{$dataset}{'post_snapshot_script'} and !$args{'readonly'}) {
|
if ($config{$dataset}{'post_snapshot_script'}) {
|
||||||
if (!$presnapshotfailure or $config{$dataset}{'force_post_snapshot_script'}) {
|
if (!$presnapshotfailure or $config{$dataset}{'force_post_snapshot_script'}) {
|
||||||
$ENV{'SANOID_TARGET'} = $dataset;
|
$ENV{'SANOID_TARGET'} = $dataset;
|
||||||
$ENV{'SANOID_SNAPNAME'} = $snapname;
|
$ENV{'SANOID_SNAPNAME'} = $snapname;
|
||||||
if ($args{'verbose'}) { print "executing post_snapshot_script '".$config{$dataset}{'post_snapshot_script'}."' on dataset '$dataset'\n"; }
|
if ($args{'verbose'}) { print "executing post_snapshot_script '".$config{$dataset}{'post_snapshot_script'}."' on dataset '$dataset'\n"; }
|
||||||
|
|
||||||
|
if (!$args{'readonly'}) {
|
||||||
runscript('post_snapshot_script',$dataset);
|
runscript('post_snapshot_script',$dataset);
|
||||||
|
}
|
||||||
|
|
||||||
delete $ENV{'SANOID_TARGET'};
|
delete $ENV{'SANOID_TARGET'};
|
||||||
delete $ENV{'SANOID_SNAPNAME'};
|
delete $ENV{'SANOID_SNAPNAME'};
|
||||||
|
|
Loading…
Reference in a new issue