mirror of https://github.com/jimsalterjrs/sanoid
Merge pull request #335 from phreaker0/catch-some-errors
Catch some errors
This commit is contained in:
commit
189f9335a5
19
syncoid
19
syncoid
|
|
@ -124,6 +124,12 @@ if (!defined $args{'recursive'}) {
|
||||||
if ($debug) { print "DEBUG: recursive sync of $sourcefs.\n"; }
|
if ($debug) { print "DEBUG: recursive sync of $sourcefs.\n"; }
|
||||||
my @datasets = getchilddatasets($sourcehost, $sourcefs, $sourceisroot);
|
my @datasets = getchilddatasets($sourcehost, $sourcefs, $sourceisroot);
|
||||||
|
|
||||||
|
if (!@datasets) {
|
||||||
|
warn "CRITICAL ERROR: no datasets found";
|
||||||
|
@datasets = ();
|
||||||
|
$exitcode = 2;
|
||||||
|
}
|
||||||
|
|
||||||
my @deferred;
|
my @deferred;
|
||||||
|
|
||||||
foreach my $datasetProperties(@datasets) {
|
foreach my $datasetProperties(@datasets) {
|
||||||
|
|
@ -263,6 +269,12 @@ sub syncdataset {
|
||||||
|
|
||||||
my $sync = getzfsvalue($sourcehost,$sourcefs,$sourceisroot,'syncoid:sync');
|
my $sync = getzfsvalue($sourcehost,$sourcefs,$sourceisroot,'syncoid:sync');
|
||||||
|
|
||||||
|
if (!defined $sync) {
|
||||||
|
# zfs already printed the corresponding error
|
||||||
|
if ($exitcode < 2) { $exitcode = 2; }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($sync eq 'true' || $sync eq '-' || $sync eq '') {
|
if ($sync eq 'true' || $sync eq '-' || $sync eq '') {
|
||||||
# empty is handled the same as unset (aka: '-')
|
# empty is handled the same as unset (aka: '-')
|
||||||
# definitely sync this dataset - if a host is called 'true' or '-', then you're special
|
# definitely sync this dataset - if a host is called 'true' or '-', then you're special
|
||||||
|
|
@ -985,6 +997,11 @@ sub getzfsvalue {
|
||||||
open FH, "$rhost $mysudocmd $zfscmd get -H $property $fsescaped |";
|
open FH, "$rhost $mysudocmd $zfscmd get -H $property $fsescaped |";
|
||||||
my $value = <FH>;
|
my $value = <FH>;
|
||||||
close FH;
|
close FH;
|
||||||
|
|
||||||
|
if (!defined $value) {
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
my @values = split(/\t/,$value);
|
my @values = split(/\t/,$value);
|
||||||
$value = $values[2];
|
$value = $values[2];
|
||||||
return $value;
|
return $value;
|
||||||
|
|
@ -1483,7 +1500,7 @@ sub getreceivetoken() {
|
||||||
my ($rhost,$fs,$isroot) = @_;
|
my ($rhost,$fs,$isroot) = @_;
|
||||||
my $token = getzfsvalue($rhost,$fs,$isroot,"receive_resume_token");
|
my $token = getzfsvalue($rhost,$fs,$isroot,"receive_resume_token");
|
||||||
|
|
||||||
if ($token ne '-' && $token ne '') {
|
if (defined $token && $token ne '-' && $token ne '') {
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue