I would like an email notification everytime a successful backup has taken place using BackupPC which I have installed on Ubuntu 16.04 server. BackupPC doesn't email you notifications unless a backup has failed. When I run the following script, I get the email saying its "failed".
I place the following in the backup settings:
$Conf{DumpPostUserCmd} =
/var/lib/backuppc/backuppc_notification_email.sh $xferOK $host $type
$client $hostIP $share $XferMethod $sshPath $cmdType
And here is the shell script:
#!/bin/bash
# script to send simple email
# Email To ?
EMAIL="[email protected]"
# Email text/message
EMAILMESSAGE="/var/lib/backuppc/emailmessage.txt"
# Grab the status variables
xferOK=$1
host=$2
type=$3
client=$4
hostIP=$5
share=$6
XferMethod=$7
sshPath=$8
cmdType=$9
# Check if backup succeeded or not.
if [[ $xferOK == 1 ]]; then
STATUS="has been SUCCESSFUL"
else
STATUS="has FAILED"
fi
# email subject
SUBJECT="[BackupPC] $STATUS for host: $client"
# Email text/message
echo "The filesystem backup for $host $STATUS" > $EMAILMESSAGE
echo "-----------------------------------------" >>$EMAILMESSAGE
echo "Type: $type" >>$EMAILMESSAGE
echo "Client: $client" >>$EMAILMESSAGE
echo "Host: $host" >>$EMAILMESSAGE
echo "Host IP: $hostIP" >>$EMAILMESSAGE
echo "Share: $share" >>$EMAILMESSAGE
echo "XferMethod: $XferMethod" >>$EMAILMESSAGE
echo "sshPath: $sshPath" >>$EMAILMESSAGE
echo "cmdType: $cmdType" >>$EMAILMESSAGE
# send an email using /bin/mail
/usr/sbin/sendmail -v "$EMAIL" "$SUBJECT" < $EMAILMESSAGE
The following is the email message I receive:
The filesystem backup for has FAILED
-----------------------------------------
Type:
Client:
Host:
Host IP:
Share:
XferMethod:
sshPath:
cmdType:
I would like to know why the email doesn't have the relevant information as stated in my shell script, and why it says FAILED?