Article 51PJ7 Rsync Script with cron and email notification

Rsync Script with cron and email notification

by
opeth281
from LinuxQuestions.org on (#51PJ7)
Hi to All,

The idea is to have a crontab in order to run a script that backs up my local files to my remote server. The problem is that if there are too many files to transfer (Example: I ripped a DVD in the last hour) the actual backup may take longer than 60 minutes. So I want to make script to check if my backup script, based on rsync, is running. I have managed to do that with flock. The quetion is that: When the Rsync starts, i want to send an email with all the names of the files that will be backup. If the connection lost during disconnections, i need to mail me which files has been transferred with success and not .If the rsync finished with success , then send an email that all the listed files have been sent with success. If the rsync has nothing to sent, don't sent an email.

Script:

Code:rsync -av --append --partial --bwlimit=64 --progress -e "ssh -p 22" root@19x.xxx.xxx.xxx:/mnt/To_Office/ /mnt/Office_files/
if [ "$?" -eq "0" ]
then
ssh -p 22 root@19x.xxx.xxx.xxx "rm -f /mnt/To_Office/*"
else
echo "Error while transferring data "
fiCrontab:

Code:15 * * * * /usr/bin/flock -n /root/scripts/To_Office.lck sh /root/scripts/To_Office.shAny help is much appreciated. Many thanks..latest?d=yIl2AUoC8zA latest?i=ky-Ack7H73w:KvRgwg6Id60:F7zBnMy latest?i=ky-Ack7H73w:KvRgwg6Id60:V_sGLiP latest?d=qj6IDK7rITs latest?i=ky-Ack7H73w:KvRgwg6Id60:gIN9vFwky-Ack7H73w
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments