Am Montag, 24. März 2008 schrieb Kaushal Shriyan:

> So the Final script looks like

Is it the final script :-) ?

> #!/bin/bash
> #rsync mysql database shell script
> #author kaushal
> #bash script file name rsync_mysql.sh
> #created on 24/03/2008
>
> TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
>
> if /usr/bin/rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/ 2>&1 |
> /usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s "host77 DB
> refresh daily" [EMAIL PROTECTED]
>
> then
>         echo "Success"
> else
>         echo "Please check the file rsync-${TIMESTAMP}.log for errors."
> fi
>
> Please let me know if its correct

There's no need for the if-then-else part anymore. You get the whole output 
mailed to the given address. However, if you follow Collins very good 
proposal, you could do with:

if /usr/bin/rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/ 
> /tmp/rsync-${TIMESTAMP}.log 2>&1
then
        subj_prefix="Success"
else
        subj_prefix="Error"
fi
cat /tmp/rsync-${TIMESTAMP}.log| /usr/bin/mailx -s "${subj_prefix}: host77 DB 
refresh daily" [EMAIL PROTECTED]

So that you can tell from the subject wether the command was succesful or not.

Bye...

        Dirk

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to