Hello Freinds,
I am in need of a shell script whiich rsyncs a folder from a server to my machine. My major concern is not a script that rysnc's but it should send a mail if the rsync failed for some reason while copying the files.. For example the remote server might go down in the middle of the copying or my machine can also be down.
How can i impliiment this? I hope i would get some help from you guys..

Looking for your updates..

Thanks,
Santhosh

Here's a quick one to get you started:

#!/bin/bash
rsync -aze ssh username@server:/path/on/remote/box /local/path 2> /home/err.log
if [ -s /home/err.log ] ;  then
    # file is not empty, some error has occured, do your email here
    echo "error occured!" ;
else
    echo "no error occured, everything went fine!" ;
fi

Obviously, you need to plug in the email portion...

I always throw in -z for rsync for the added compression benefit, and I also always use -e ssh to send it over SSH so it's encrypted.

HTH

-Josh

Hi Santhosh

Did you find something? If not... I got a project running which does exactly what you need. Have a look at smarbs.sourceforge.net.

I'd be glad if you'd tell me if it worked for you!

Cheers
Jan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.