Rsync Email Notfication


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rsync Email Notfication
# 1  
Old 12-30-2014
Rsync Email Notfication

Hi All.

I am currently running several rsyncs from various red hat servers to one central location. These write out a daily log to the local file system. I would like to continue that but i would like to also send a email notification on the completion of the rsync.

the script i am running is as follows


Code:
#!/bin/bash
if [ -e /raid/.synclock ]
then
rsync -aWv  --stats --progress  --ignore-errors --exclude '._*' --exclude '.HS*' --exclude '.DS_Store' --exclude '.TemporaryItems/*' --exclude '.TemporaryItems' --exclude '.VolumeIcon.i
cns'  --delete  --delete-excluded  /raid/  111.11.8.12:/gpfs/STUDIO_RSYNCS/PEARTREE/ >> /raid/Rsync_logs/Peartree_rsync.`date +%w`.log 2>&1

else
	echo "lock file not present. Exiting"  >> /raid/Rsync_logs/Peartree_rsync.`date +%w`.log 2>&1
fi

is it possible to add the email notification of completion into this script please

thanks in advance

Treds

Last edited by Don Cragun; 12-31-2014 at 06:28 AM.. Reason: Change ICODE tags to CODE tags.
# 2  
Old 12-30-2014
In the simplest case just call mail once rsync is finished:

Code:
#!/bin/bash

if [ -e /raid/.synclock ]
then

    rsync -aWv --stats --progress --ignore-errors --exclude '._*' --exclude '.HS*' --exclude '.DS_Store' \
        --exclude '.TemporaryItems/*' --exclude '.TemporaryItems' --exclude '.VolumeIcon.icns' --delete \
        --delete-excluded /raid/ 111.11.8.12:/gpfs/STUDIO_RSYNCS/PEARTREE/ >> /raid/Rsync_logs/Peartree_rsync.`date +%w`.log 2>&1

    echo "Exit status was: $?" | mail -s "Rsync finished" treds@company.com
else
    echo "lock file not present. Exiting" >> /raid/Rsync_logs/Peartree_rsync.`date +%w`.log 2>&1
fi

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 12-31-2014
For the future:
Please use the icode tags only for single words, not for code blocks.
For code blocks, please use the code tags. (it even has the word CODE on its icon!)

Thank you
# 4  
Old 01-07-2015
Hi Chubler

this works well only issue is the email is returning the

Code:
Exit status was: 23

Which suggest a error.

But when i tail the end of the actual sync log it seems correct


Code:
Number of files: 257744
Number of files transferred: 1445
Total file size: 10112210994280 bytes
Total transferred file size: 23870232297 bytes
Literal data: 23870275332 bytes
Matched data: 0 bytes
File list size: 6699712
File list generation time: 0.136 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 23879965292
Total bytes received: 44147

sent 23879965292 bytes  received 44147 bytes  7534314.38 bytes/sec
total size is 10112210994280  speedup is 423.46

its seems i get the same error on every server.

regards
Treds

Last edited by Don Cragun; 01-07-2015 at 02:49 PM.. Reason: Change QUOTE tags to CODE tags and add missing CODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync Error: rsync: link_stat failed: No such file or directory (2)

I wish to copy all the files & folder under /web/Transfer_Files/data/ on mymac1 (Linux) to remote server mybank.intra.com (Solaris 10) /tmp/ location I am using Ansible tool synchronize module which triggers the unix rsync command as below:rsync --delay-updates -F --compress --archive --rsh=ssh... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Email Notifications on Cron Bash Error Only cp mv rsync

Wondering if anyone can point me to an example of how to setup a bash script that executes cp mv and rsync commands and only sends an email if there were errors with any of those commands and what the errors are. In addition it should email if the cron event to execute the script fails, or in... (1 Reply)
Discussion started by: consultant
1 Replies

3. Shell Programming and Scripting

Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping my code ( echo "From: $FROM" echo "To: $MAILTO" echo "CC: $CC" echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed;... (6 Replies)
Discussion started by: mirwasim
6 Replies

4. SuSE

Send outgoing email to my GroupWise email

Dear users, I have Linux server whose versions are Suse 10 SP 3 and Suse 11. I am trying to send email from these servers to my GroupWise email account. In /etc/postfix/main.cf file, The current value of MYHOSTNAME is LINUX.LOCAL. What should be the right value of MYHOSTNAME? Is... (0 Replies)
Discussion started by: JDBA
0 Replies

5. Shell Programming and Scripting

Add Email Notification to Rsync

HI what i need to be able to do is add a email to the end of a rsync. my current ion configures writes a daily log to disk, but real want to send the log to a central email address. The current script is as below, is this possible? #!/bin/bash if then rsync -aWv --stats progress... (3 Replies)
Discussion started by: treds
3 Replies

6. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

7. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

8. Solaris

Send an email from Solaris using Linux email server

Hello everyone I have a problem and I need your help: I have a Solaris 10 and Solaris 8 UNIX Servers, and Linux Centos4 as email server. I need send an email from Solaris servers preferably using Centos4 email server. I have no mail service configured in my Solaris computers (1 Reply)
Discussion started by: aflores
1 Replies

9. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

10. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question