Step 1
Go to Edit Config->Backup Setting and add the following lines into the DumpPostUserCmd
/opt/BackupPC/email_sample.sh $xferOK $host $type $client $hostIP $share $XferMethod $sshPath $cmdType
Before that we have to create email_sample.sh in that particular locations.
step 2
add the following scipt in email_sample.sh file and create a txt file in /tmpas emailmessage.txt
#!/bin/bash
# script to send simple email
# Email To ?
EMAIL="your mail address"
# Email text/message
EMAILMESSAGE="/tmp/emailmessage.txt"
# Grab the status variables
xferOK=$1
host=$2
type=$3
client=$4
#hostIP=$5
share=$6
XferMethod=$7
#TopDir=$8
#cmdType=$9
#Extract the info file
#LOG_FILE="/u01/BackupPC/pc/$host//backupInfo"
LOG_FILE=`ls -t /u01/BackupPC/pc/$host/*/backupInfo | /usr/bin/head -1`
# Check if backup succeeded or not.
if [[ $xferOK == 1 ]]; then
STATUS="SUCCESS"
else
STATUS="FAILED"
fi
# email subject
SUBJECT="[BackupPC] $STATUS for host: $client"
# Email text/message
echo "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 "BackupPath: $TopDir" >>$EMAILMESSAGE
#echo "cmdType: $cmdType" >>$EMAILMESSAGE
echo "BackupDetails: $LOG_FILE" >>$EMAILMESSAGE
cat $LOG_FILE >>$EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
I have # some details if you required that you can enable it.
Then change the owner to backuppcuser and provide execute permission
chown backuppc:backuppc email_sample.sh
chmod +x email_sample.sh
Now you will receive success and failure message whenever the backup start.
Go to Edit Config->Backup Setting and add the following lines into the DumpPostUserCmd
/opt/BackupPC/email_sample.sh $xferOK $host $type $client $hostIP $share $XferMethod $sshPath $cmdType
Before that we have to create email_sample.sh in that particular locations.
step 2
add the following scipt in email_sample.sh file and create a txt file in /tmpas emailmessage.txt
#!/bin/bash
# script to send simple email
# Email To ?
EMAIL="your mail address"
# Email text/message
EMAILMESSAGE="/tmp/emailmessage.txt"
# Grab the status variables
xferOK=$1
host=$2
type=$3
client=$4
#hostIP=$5
share=$6
XferMethod=$7
#TopDir=$8
#cmdType=$9
#Extract the info file
#LOG_FILE="/u01/BackupPC/pc/$host//backupInfo"
LOG_FILE=`ls -t /u01/BackupPC/pc/$host/*/backupInfo | /usr/bin/head -1`
# Check if backup succeeded or not.
if [[ $xferOK == 1 ]]; then
STATUS="SUCCESS"
else
STATUS="FAILED"
fi
# email subject
SUBJECT="[BackupPC] $STATUS for host: $client"
# Email text/message
echo "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 "BackupPath: $TopDir" >>$EMAILMESSAGE
#echo "cmdType: $cmdType" >>$EMAILMESSAGE
echo "BackupDetails: $LOG_FILE" >>$EMAILMESSAGE
cat $LOG_FILE >>$EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
I have # some details if you required that you can enable it.
Then change the owner to backuppcuser and provide execute permission
chown backuppc:backuppc email_sample.sh
chmod +x email_sample.sh
Now you will receive success and failure message whenever the backup start.
No comments:
Post a Comment