return a non zero exit code if there was a problem replicating datasets
This commit is contained in:
parent
d1153a244f
commit
7c68ef5e8f
16
syncoid
16
syncoid
|
@ -97,6 +97,7 @@ my $targetsudocmd = $targetisroot ? '' : $sudocmd;
|
||||||
my %avail = checkcommands();
|
my %avail = checkcommands();
|
||||||
|
|
||||||
my %snaps;
|
my %snaps;
|
||||||
|
my $exitcode = 0;
|
||||||
|
|
||||||
## break here to call replication individually so that we ##
|
## break here to call replication individually so that we ##
|
||||||
## can loop across children separately, for recursive ##
|
## can loop across children separately, for recursive ##
|
||||||
|
@ -127,7 +128,7 @@ if ($targethost ne '') {
|
||||||
close FH;
|
close FH;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 0;
|
exit $exitcode;
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
@ -186,6 +187,7 @@ sub syncdataset {
|
||||||
# make sure target is not currently in receive.
|
# make sure target is not currently in receive.
|
||||||
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
||||||
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
||||||
|
if ($exitcode < 1) { $exitcode = 1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +238,7 @@ sub syncdataset {
|
||||||
$newsyncsnap = getnewestsnapshot($sourcehost,$sourcefs,$sourceisroot);
|
$newsyncsnap = getnewestsnapshot($sourcehost,$sourcefs,$sourceisroot);
|
||||||
if ($newsyncsnap eq 0) {
|
if ($newsyncsnap eq 0) {
|
||||||
warn "CRITICAL: no snapshots exist on source $sourcefs, and you asked for --no-sync-snap.\n";
|
warn "CRITICAL: no snapshots exist on source $sourcefs, and you asked for --no-sync-snap.\n";
|
||||||
|
if ($exitcode < 1) { $exitcode = 1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,6 +295,7 @@ sub syncdataset {
|
||||||
# make sure target is (still) not currently in receive.
|
# make sure target is (still) not currently in receive.
|
||||||
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
||||||
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
||||||
|
if ($exitcode < 1) { $exitcode = 1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
system($synccmd) == 0
|
system($synccmd) == 0
|
||||||
|
@ -318,6 +322,7 @@ sub syncdataset {
|
||||||
# make sure target is (still) not currently in receive.
|
# make sure target is (still) not currently in receive.
|
||||||
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
||||||
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
||||||
|
if ($exitcode < 1) { $exitcode = 1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,9 +330,12 @@ sub syncdataset {
|
||||||
if ($debug) { print "DEBUG: $synccmd\n"; }
|
if ($debug) { print "DEBUG: $synccmd\n"; }
|
||||||
|
|
||||||
if ($oldestsnap ne $newsyncsnap) {
|
if ($oldestsnap ne $newsyncsnap) {
|
||||||
system($synccmd) == 0
|
my $ret = system($synccmd);
|
||||||
or warn "CRITICAL ERROR: $synccmd failed: $?";
|
if ($ret != 0) {
|
||||||
|
warn "CRITICAL ERROR: $synccmd failed: $?";
|
||||||
|
if ($exitcode < 1) { $exitcode = 1; }
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!$quiet) { print "INFO: no incremental sync needed; $oldestsnap is already the newest available snapshot.\n"; }
|
if (!$quiet) { print "INFO: no incremental sync needed; $oldestsnap is already the newest available snapshot.\n"; }
|
||||||
}
|
}
|
||||||
|
@ -380,6 +388,7 @@ sub syncdataset {
|
||||||
# make sure target is (still) not currently in receive.
|
# make sure target is (still) not currently in receive.
|
||||||
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
if (iszfsbusy($targethost,$targetfs,$targetisroot)) {
|
||||||
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
warn "Cannot sync now: $targetfs is already target of a zfs receive process.\n";
|
||||||
|
if ($exitcode < 1) { $exitcode = 1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,6 +919,7 @@ sub getmatchingsnapshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
# if we got this far, we failed to find a matching snapshot.
|
# if we got this far, we failed to find a matching snapshot.
|
||||||
|
if ($exitcode < 2) { $exitcode = 2; }
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
print "CRITICAL ERROR: Target $targetfs exists but has no snapshots matching with $sourcefs!\n";
|
print "CRITICAL ERROR: Target $targetfs exists but has no snapshots matching with $sourcefs!\n";
|
||||||
|
|
Loading…
Reference in New Issue