Gentoo Archives: gentoo-user

From: Kaushal Shriyan <kaushalshriyan@×××××.com>
To: gentoo@××××××××××××××××××.com
Cc: gentoo-user@l.g.o
Subject: Re: [gentoo-user] rsync script
Date: Fri, 21 Mar 2008 08:59:20
Message-Id: 6b16fb4c0803210159nc6824b0g1eb88067c8ef75e6@mail.gmail.com
In Reply to: Re: [gentoo-user] rsync script by Collin Starkweather
1 On Fri, Mar 21, 2008 at 2:03 PM, Collin Starkweather <
2 gentoo@××××××××××××××××××.com> wrote:
3
4 > Quoting Kaushal Shriyan <kaushalshriyan@×××××.com>:
5 >
6 > > On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon <alan.mckinnon@×××××.com
7 > >
8 > > wrote:
9 > >
10 > >> On Friday 21 March 2008, Kaushal Shriyan wrote:
11 > >> > Hi
12 > >> >
13 > >> > MAILTO=kaushal@×××××××.com
14 > >> > 0 18 * * * rsync -av /var/lib/mysql kaushal@host77:/var/lib/
15 >
16 > Run rsync through a script that tests the exit value, then prints an
17 > error message if the exit value is not equal to 0 and nothing
18 > otherwise. Run the script from cron and it will send you an e-mail if
19 > there is a problem.
20 >
21 > In bash, $? is the exit value of the last command. This is a bit
22 > verbose, but you could put the following in rsync-host77.sh:
23 >
24 > #!/bin/bash
25 > TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
26 > rsync -av /bogus foo@bar:/bogus/ &>rsync-${TIMESTAMP}.log
27 > EXITVALUE=$?
28 > if [[ "${EXITVALUE}" -ne "0" ]]
29 > then
30 > echo "Error: rsync exited with status ${EXITVALUE}"
31 > echo " "
32 > echo "Please check the file rsync-${TIMESTAMP}.log for errors."
33 > fi
34 >
35 > To find exit values and their corresponding meanings, search for "EXIT
36 > VALUES" in
37 >
38 > http://www.linuxmanpages.com/man1/rsync.1.php
39 >
40 > Hope this helps,
41 >
42 > -Collin
43 >
44 > --
45 > Collin Starkweather, Ph.D.
46 > http://www.linkedin.com/in/collinstarkweather
47 >
48 > --
49 > gentoo-user@l.g.o mailing list
50 >
51 >
52 Hi Collin
53
54 Thanks Collin
55
56 Correct me if i am wrong please. I want to understand your script
57
58 step 1 : put the above code in text file and name it as rsync-host77.sh in
59 the folder /home/kaushal in the machine where rsync command will execute
60
61 step 2 :
62
63 cd /home/kaushal
64 $crontab -e
65
66 0 18 * * * rsync -host77.sh
67
68 If i want to run the rsync script at 6 pm everyday
69
70 Also where will the "rsync-${TIMESTAMP}.log" file will be located, I believe
71 it will be in /home/kaushal folder. Lets say if i have to put
72 "rsync-${TIMESTAMP}.log" in /tmp folder
73
74 then the above rsync line would look like
75
76 rsync -av /bogus foo@bar:/bogus/ &>/tmp/rsync-${TIMESTAMP}.log
77
78 is that correct what i understand from your email
79
80 Thanks a Lot again
81
82 Thanks and Regards
83
84 Kaushal

Replies

Subject Author
Re: [gentoo-user] rsync script Collin Starkweather <gentoo@××××××××××××××××××.com>