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.
This commit is contained in:
@@ -155,7 +155,10 @@ message 20 "BACKUP_FILES=$BACKUP_FILES"
|
|||||||
# the exit value from various commands more easily.
|
# the exit value from various commands more easily.
|
||||||
(
|
(
|
||||||
message 1 "preparing tapes"
|
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}"
|
rm -f "${VOLNO_FILE}"
|
||||||
|
|
||||||
message 1 "processing backup directories"
|
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
|
# 'rsh' doesn't exit with the exit status of the remote command. What
|
||||||
# stupid lossage. TODO: think of a reliable workaround.
|
# stupid lossage. TODO: think of a reliable workaround.
|
||||||
if [ $? -ne 0 ] ; then
|
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
|
# I'm assuming that the tar will have written an empty
|
||||||
# file to the tape, otherwise I should do a cat here.
|
# file to the tape, otherwise I should do a cat here.
|
||||||
else
|
else
|
||||||
@@ -238,17 +241,17 @@ message 20 "BACKUP_FILES=$BACKUP_FILES"
|
|||||||
else
|
else
|
||||||
echo "No miscellaneous files specified"
|
echo "No miscellaneous files specified"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
message 1 "final cleanup"
|
message 1 "final cleanup"
|
||||||
|
|
||||||
$MT_REWIND "${TAPE_FILE}"
|
$MT_REWIND "${TAPE_FILE}"
|
||||||
$MT_OFFLINE "${TAPE_FILE}"
|
$MT_OFFLINE "${TAPE_FILE}"
|
||||||
echo "."
|
echo "."
|
||||||
) 2>&1 | tee -a "${LOGFILE}"
|
) 2>&1 | tee -a "${LOGFILE}"
|
||||||
|
RC=$?
|
||||||
|
|
||||||
if test "${ADMINISTRATOR}" != NONE; then
|
if test "${ADMINISTRATOR}" != NONE; then
|
||||||
echo "Sending the dump log to ${ADMINISTRATOR}"
|
echo "Sending the dump log to ${ADMINISTRATOR}"
|
||||||
mail -s "Results of backup started ${startdate}" ${ADMINISTRATOR} < "${LOGFILE}"
|
mail -s "Results of backup started ${startdate}" ${ADMINISTRATOR} < "${LOGFILE}"
|
||||||
fi
|
fi
|
||||||
|
exit $RC
|
||||||
# EOF
|
# EOF
|
||||||
|
|||||||
@@ -311,7 +311,9 @@ backup_host() {
|
|||||||
CMD="exec ${TAR_PART1} -f \"${TAPE_FILE}\" $@"
|
CMD="exec ${TAR_PART1} -f \"${TAPE_FILE}\" $@"
|
||||||
message 10 "CMD: $CMD"
|
message 10 "CMD: $CMD"
|
||||||
sh -c "$CMD"
|
sh -c "$CMD"
|
||||||
message 10 "RC: $?"
|
RC=$?
|
||||||
|
message 10 "RC: $RC"
|
||||||
|
return $RC
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user