Wrap scripts to send error mails when they fail; properly fail backup2me.sh
This commit is contained in:
parent
dfcdd93dd1
commit
e4b1845015
@ -67,12 +67,12 @@ echo "Done"
|
|||||||
### Create local model of the remote's backup directory tree and send it ###
|
### Create local model of the remote's backup directory tree and send it ###
|
||||||
echo "Directory structure..."
|
echo "Directory structure..."
|
||||||
mkdir -p "$BACKUP_CONTENTS_PATH"
|
mkdir -p "$BACKUP_CONTENTS_PATH"
|
||||||
eval ${RSYNC_STRUCTURE_CMD[*]}
|
eval ${RSYNC_STRUCTURE_CMD[*]} || exit 1
|
||||||
echo "Done"
|
echo "Done"
|
||||||
|
|
||||||
### Backup home directory except some unwanted files ###
|
### Backup home directory except some unwanted files ###
|
||||||
echo "Backup data..."
|
echo "Backup data..."
|
||||||
eval ${RSYNC_DATA_CMD[*]}
|
eval ${RSYNC_DATA_CMD[*]} || exit 1
|
||||||
echo "Done"
|
echo "Done"
|
||||||
|
|
||||||
### Remove local model of the backup directory tree ###
|
### Remove local model of the backup directory tree ###
|
||||||
|
17
mail_wrap_script.sh
Executable file
17
mail_wrap_script.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT=$1
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
OUTPUT=$($SCRIPT "$@" 2>&1)
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
MAILTO=$(cat "$HOME/.admin_mail")
|
||||||
|
echo "Sending error mail"
|
||||||
|
echo -e "An error occured during the execution of $SCRIPT.\n\n$OUTPUT" | mailx -s "$(hostname) $SCRIPT failure" "$MAILTO"
|
||||||
|
echo "Sent"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "$OUTPUT"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user