1) I'm a developer. 2) I use one special machine as a CVS server, generic storage ( an electronic attic ), as a web server of online documentation ( such as the python documentation, or SGI STL docs ). 3) I would like to add a hard drive to that system that mirrors the system drive. Someone suggested that I use rsync for this purpose. Called by a cron job that starts at 2:00am. I also want to build a list of changed files to make into a tarball that gets copied to a remote machine where it gets backed up to tape ( for which I was told --dryrun would be used). 4) The basic idea as I understand it is to issue a command: rsync -avv / /mirror. 5) I need to know if rsync fails. It is useless to me if it fails and then fails to notify me. The man pages fail to totally describe return values, but I assume that they do describe success/failure. So I wrote a script to test this out. #!/bin/sh export res=$(rsync -avv / /mirror) echo $(res) I then mounted a partition of 15M on /mirror, and executed the script to get an idea of how rsync behaved when it ran out space. rsync seems to hang in the middle of /etc . df shows that only 75% of /mirror is filled/ Any idea why rsync hangs. 6) I'm a bit confused by the notation for rsync excludes. I would like to exclude certain things and seem to be failing. I would like to exclude things such as ( matching by grep ) "^/proc" "^/mirror" "^/tmp". Of course the ^ in front indicates that I do not want to exclude things like /home/olczyk/mirror. TIA
On Mon, Oct 22, 2001 at 01:18:47AM +0000, Thaddeus L. Olczyk wrote: ...> 5) I need to know if rsync fails. It is useless to me if it fails > and then fails to notify me. The man pages fail to totally describe > return values, but I assume that they do describe success/failure. > So I wrote a script to test this out. > > #!/bin/sh > export res=$(rsync -avv / /mirror) > echo $(res)I don't understand that syntax. /bin/sh for me reports syntax error: `(' unexpected Under ksh I would expect that to be equivalent $(...) to be equivalent to `...` but then what would echo `res` mean?> I then mounted a partition of 15M on /mirror, and executed the script > to get an idea of how rsync behaved when it ran out space. > > rsync seems to hang in the middle of /etc . > df shows that only 75% of /mirror is filled/ > > Any idea why rsync hangs.Perhaps it's a problem with your script?> 6) I'm a bit confused by the notation for rsync excludes. I would like > to exclude certain things and seem to be failing. I would like to > exclude things such as ( matching by grep ) "^/proc" "^/mirror" > "^/tmp". Of course the ^ in front indicates that I do not want to > exclude things like /home/olczyk/mirror.Rsync excludes are not as powerful as regular expressions. However, if you start them with a slash, they match only the beginning of a path. So you should be able to just say "/proc", "/mirror", "/tmp", etc. - Dave Dykstra
the $(command) syntax is a ksh-specific form of backticking, which is nestable, and therefore more flexible than backticks (I always have to do all the intermediate steps into variables, and use variable substitution instead, for portability). You'll also see $((arithmetic expression)), and even ((arithmetic expression with variables expanded though not prefixed with $)) with ksh. Dave Korn seems to have thought of everything. Anyway, on RS/6000 systems, (and maybe some other ones), /bin is a symlink to /usr/bin, which contains sh, which is a symlink to ksh. Under AIX, if you want a bourne shell, you use bsh. Now, I don't know why he would want to run it, store the whole output in a variable, then echo the variable. that hides the output until it's completely finished. I think what he actually wants is $? (in csh, $status). Maybe something like most people use: #!/bin/sh if rsync -avv / /mirror then echo successful else echo unsuccessful fi Actually, mine is more along the lines of #!/usr/bin/perl while(system("rsync -options source destination")){ <stuff to do if it failed> } Since a shell fork with a non-zero exit is true, thus until it's false, it failed. +WARNING TO THADDEUS+ your syntax will not do what you want. /mirror is under / that means the every time you rsync, you put the contents of /mirror into /mirror/mirror, then /mirror/mirror/mirror. You double the info every sync (+/- changes) man rsync note --exclude Tim Conway tim.conway@philips.com 303.682.4917 Philips Semiconductor - Longmont TC 1880 Industrial Circle, Suite D Longmont, CO 80501 Available via SameTime Connect within Philips Available as n9hmg on AIM perl -e 'print pack(nnnnnnnnnnnn, 19061,29556,8289,28271,29800,25970,8304,25970,27680,26721,25451,25970), ".\n" ' "There are some who call me.... Tim?" Dave Dykstra <dwd@bell-labs.com>@lists.samba.org on 10/22/2001 10:12:41 AM Sent by: rsync-admin@lists.samba.org To: "Thaddeus L. Olczyk" <olczyk@interaccess.com> cc: rsync@samba.org (bcc: Tim Conway/LMT/SC/PHILIPS) Subject: Re: Using rsync to mirror a hard drive. Classification: On Mon, Oct 22, 2001 at 01:18:47AM +0000, Thaddeus L. Olczyk wrote: ...> 5) I need to know if rsync fails. It is useless to me if it fails > and then fails to notify me. The man pages fail to totally describe > return values, but I assume that they do describe success/failure. > So I wrote a script to test this out. > > #!/bin/sh > export res=$(rsync -avv / /mirror) > echo $(res)I don't understand that syntax. /bin/sh for me reports syntax error: `(' unexpected Under ksh I would expect that to be equivalent $(...) to be equivalent to `...` but then what would echo `res` mean?> I then mounted a partition of 15M on /mirror, and executed the script > to get an idea of how rsync behaved when it ran out space. > > rsync seems to hang in the middle of /etc . > df shows that only 75% of /mirror is filled/ > > Any idea why rsync hangs.Perhaps it's a problem with your script?> 6) I'm a bit confused by the notation for rsync excludes. I would like > to exclude certain things and seem to be failing. I would like to > exclude things such as ( matching by grep ) "^/proc" "^/mirror" > "^/tmp". Of course the ^ in front indicates that I do not want to > exclude things like /home/olczyk/mirror.Rsync excludes are not as powerful as regular expressions. However, if you start them with a slash, they match only the beginning of a path. So you should be able to just say "/proc", "/mirror", "/tmp", etc. - Dave Dykstra
Thaddeus L. Olczyk
2001-Oct-24 17:31 UTC
Update (Was: Using rsync to mirror a hard drive.)
Just to let people know. There are several things which I discovered but will not comment on ( for example compiling with debug options on--BTW you have to manually modify Makefiles to turn on debugging. It seems there is no option for it in configure-- and using gdb causes rsync to terminate prematurely ). There just a mishmash of facts that are hard to keep track of. I got exclude to work. When I exclude /dev rsync does not hang, when I do not exclude /dev rsync hangs.