Java Mailing List Archive

http://www.redhatconfig.com/

Home » Gentoo Linux »

Re: [gentoo-user] rsync script

Kaushal Shriyan

2008-03-21

Replies: Find Java Web Hosting

Author LoginPost Reply
On Fri, Mar 21, 2008 at 2:03 PM, Collin Starkweather <gentoo@collinstarkweather.com> wrote:
Quoting Kaushal Shriyan <kaushalshriyan@gmail.com>:

> On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon <alan.mckinnon@gmail.com>
> wrote:
>
>> On Friday 21 March 2008, Kaushal Shriyan wrote:
>> > Hi
>> >
>> > MAILTO=kaushal@example.com
>> > 0 18 * * * rsync -av /var/lib/mysql kaushal@host77:/var/lib/

Run rsync through a script that tests the exit value, then prints an
error message if the exit value is not equal to 0 and nothing
otherwise.  Run the script from cron and it will send you an e-mail if
there is a problem.

In bash, $? is the exit value of the last command.  This is a bit
verbose, but you could put the following in rsync-host77.sh:

  #!/bin/bash
  TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
  rsync -av /bogus foo@bar:/bogus/ &>rsync-${TIMESTAMP}.log
  EXITVALUE=$?
  if [[ "${EXITVALUE}" -ne "0" ]]
  then
        echo "Error:  rsync exited with status ${EXITVALUE}"
        echo " "
        echo "Please check the file rsync-${TIMESTAMP}.log for errors."
  fi

To find exit values and their corresponding meanings, search for "EXIT
VALUES" in

  http://www.linuxmanpages.com/man1/rsync.1.php

Hope this helps,

-Collin

--
Collin Starkweather, Ph.D.
http://www.linkedin.com/in/collinstarkweather

--

Hi Collin

Thanks Collin

Correct me if i am wrong please. I want to understand your script

step 1 : put the above code in text file and name it as rsync-host77.sh in the folder /home/kaushal in the machine where rsync command will execute

step 2 : 

cd /home/kaushal
$crontab -e
 
0 18 * * * rsync -host77.sh

If i want to run the rsync script at 6 pm everyday          

Also where will the "rsync-${TIMESTAMP}.log" file will be located, I believe it will be in /home/kaushal folder. Lets say if i have to put "rsync-${TIMESTAMP}.log" in /tmp folder

then the above rsync line would look like

rsync -av /bogus foo@bar:/bogus/ &>/tmp/rsync-${TIMESTAMP}.log

is that correct what i understand from your email

Thanks a Lot again

Thanks and Regards

Kaushal
©2008 redhatconfig.com - Jax Systems, LLC, U.S.A.