summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-11-12 12:31:24 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-11-12 12:31:24 +0200
commit76dad6d1fbed2b9c93974307198d1ac631c1a751 (patch)
tree28c56f014d449872e42e884b98c645b9ff380b73 /scripts
parenta2fd82f62285d647dac968108eee02457255eff7 (diff)
downloadtar-76dad6d1fbed2b9c93974307198d1ac631c1a751.tar.gz
Better error checking in the backup script.
* scripts/backup.in: Check exit code of MT_BEGIN * scripts/backup.sh.in (backup_host): Return meaningful code in case of remote execution. See the comment, though.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/backup.in11
-rw-r--r--scripts/backup.sh.in4
2 files changed, 10 insertions, 5 deletions
diff --git a/scripts/backup.in b/scripts/backup.in
index 087ab2c1..1093748a 100644
--- a/scripts/backup.in
+++ b/scripts/backup.in
@@ -155,7 +155,10 @@ message 20 "BACKUP_FILES=$BACKUP_FILES"
# the exit value from various commands more easily.
(
message 1 "preparing tapes"
- $MT_BEGIN "${TAPE_FILE}"
+ if ! $MT_BEGIN "${TAPE_FILE}"; then
+ echo >&2 "$0: tape initialization failed"
+ exit 1
+ fi
rm -f "${VOLNO_FILE}"
message 1 "processing backup directories"
@@ -191,7 +194,7 @@ message 20 "BACKUP_FILES=$BACKUP_FILES"
# 'rsh' doesn't exit with the exit status of the remote command. What
# stupid lossage. TODO: think of a reliable workaround.
if [ $? -ne 0 ] ; then
- echo "Backup of ${1} failed." 1>&2
+ echo "$0: backup of ${1} failed." 1>&2
# I'm assuming that the tar will have written an empty
# file to the tape, otherwise I should do a cat here.
else
@@ -238,17 +241,17 @@ message 20 "BACKUP_FILES=$BACKUP_FILES"
else
echo "No miscellaneous files specified"
fi
-
message 1 "final cleanup"
$MT_REWIND "${TAPE_FILE}"
$MT_OFFLINE "${TAPE_FILE}"
echo "."
) 2>&1 | tee -a "${LOGFILE}"
+RC=$?
if test "${ADMINISTRATOR}" != NONE; then
echo "Sending the dump log to ${ADMINISTRATOR}"
mail -s "Results of backup started ${startdate}" ${ADMINISTRATOR} < "${LOGFILE}"
fi
-
+exit $RC
# EOF
diff --git a/scripts/backup.sh.in b/scripts/backup.sh.in
index 4e739cd8..2c69ee93 100644
--- a/scripts/backup.sh.in
+++ b/scripts/backup.sh.in
@@ -311,7 +311,9 @@ backup_host() {
CMD="exec ${TAR_PART1} -f \"${TAPE_FILE}\" $@"
message 10 "CMD: $CMD"
sh -c "$CMD"
- message 10 "RC: $?"
+ RC=$?
+ message 10 "RC: $RC"
+ return $RC
fi
}