Using rsync to mirror a hard drive.

tim.conway at philips.com tim.conway at philips.com
Tue Oct 23 03:56:42 EST 2001


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 at 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 at bell-labs.com>@lists.samba.org on 10/22/2001 10:12:41 AM

Sent by:  rsync-admin at lists.samba.org


To:     "Thaddeus L. Olczyk" <olczyk at interaccess.com>
cc:     rsync at 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









More information about the rsync mailing list