rsync include / exclude

Michael C. Davis mcdavis941 at knology.net
Thu May 6 18:20:34 GMT 2004


Hi, I'm using rsync to move the contents of one drive to another as part of
upgrading from an old Linux installation to a newer one.  I have a script
which uses includes and excludes to select what to keep and what to throw
away, but for some reason my include rule isn't triggering when I think it
should.  

I've narrowed it down to a test script for a representative case which,
again, should be working but isn't.  The test script is trying to say
"include anything in /usr/etc and its subdirectories from the source tree,
and exclude everything else."  For some reason, this isn't working.
Obviously, I've misunderstood some aspect of how rsync works.  Does anyone
see the problem?  TIA.

script:
-------

    #!/bin/bash
    SRC=/home/mcdavis/mtmaxtor/
    DEST=/home/mcdavis/frommaxtor/

    # Here is a set of attempts to include, none of which work.
    rsync -aHvn --compare-dest=/ --include="/usr/etc/*" --exclude="*" $SRC
$DEST
    rsync -aHvn --compare-dest=/ --include="/usr/etc/" --exclude="*" $SRC
$DEST
    rsync -aHvn --compare-dest=/ --include="/usr/etc" --exclude="*" $SRC $DEST
    rsync -aHvn --compare-dest=/ --include="/usr/etc/**" --exclude="*" $SRC
$DEST
    rsync -aHvn --compare-dest=/ --include="/usr/etc*" --exclude="*" $SRC
$DEST
    rsync -aHvn --compare-dest=/ --include="usr/etc/*" --exclude="*" $SRC
$DEST
    rsync -aHvn --compare-dest=/ --include="usr/etc/" --exclude="*" $SRC $DEST
    rsync -aHvn --compare-dest=/ --include="usr/etc" --exclude="*" $SRC $DEST
    rsync -aHvn --compare-dest=/ --include="usr/etc/**" --exclude="*" $SRC
$DEST
    rsync -aHvn --compare-dest=/ --include="usr/etc*" --exclude="*" $SRC $DEST

    # End of script.

Here's what's in the dest prior to running the script

    > ls -l /home/mcdavis/frommaxtor
    total 0

Here's what's in the src prior to runnning the scripts/

    > ls -l /home/mcdavis/mtmaxtor/usr/etc
    total 4
    -rw-r--r--    1 root     root         3956 Mar  8  2001 wgetrc

Here's what I get when I run the script, logged in as root:

    > ./includetest.sh
    building file list ... done
    Wrote 40 bytes  Read 16 bytes  112.0 bytes per second
    Total size is 0  speedup is 0.00
    [ repeat nine more times ]






More information about the rsync mailing list