include directory, exclude contents

tim rsync at nsr500.net
Wed Dec 3 14:33:30 EST 2003


jw schultz wrote:
> On Tue, Dec 02, 2003 at 12:57:00PM -0800, tim wrote:
> 
>>Forgot to mention this:
>>
>>server:  rsync version 2.5.4  protocol version 26
>>clients: rsync version 2.4.6  protocol version 24
> 
> 
> Almost nobody can comment on the behavior of rsync versions
> from the previous millenium.  There have been too many bug
> fixes and enhancements.

Didn't realize just how old these were (RH 7.3 & 6.2 rpm's).  In any case I 
updated the clients to 2.5.4 which did not in and of itself fix the problem.

On the 43 reading of the EXCLUDE man page definitions the answer finally 
came.  Using the directory 'Cache' as an example, putting the sequence

    + Cache/
    - **/Cache/**

in the exclude file will creat the subdirectory minus its contents.  This 
works (even with prehistoric 2.5.4) based on the following:

    rsync -a --delete -e ssh --stats --exclude-from=$exclude_file \
       $client:/ /$rsync_server/$client_directory/

To test, try something like:

    rsync -a -vv -n --delete -e ssh --stats --exclude-from=$exclude_file \
       $client:/ /$rsync_server/$client_directory/ | grep Cache

Regards and thanks for the old version hint.


 >>Also I found this at http://rsync.samba.org/fom-serve/cache/93.html:
 >>
 >>  How do I use rsync to replicate a directory structure without
 >>  copying any files?
 >>
 >>  rsync -av --include '*/' --exclude '*' source-dir dest-dir
 >>
 >>How would you apply this include/exclude pair for a specific directory?
 >>FOr example,  every time a directory named 'tmp' shows up no matter where
 >>it is in the tree?
 >
 >
 > - tmp/*
 >
 > It is not necessary to explicity include it unless to
 > prevent another pattern later from excluding it.
 >
 >
 >>Thanks,
 >>Tim.
 >>
 >>tim wrote:
 >>
 >>>I'm using a simple client/server backup pull model
 >>>
 >>>rsync -a --delete -e ssh --exclude-from=$exclude path/$client.exclude \
 >>> ${client}-rsync:/ $path/$client
 >>>
 >>>but can't seem to find the right 'exclude' combination to fetch certain
 >>>directories but not their contents.  Unfortunately this was found during
 >>>a recent major restore where the excluded directories had to be manually
 >>>recreated.
 >>>
 >>>After more than 30 dry runs using variations in leading/trailing slash
 >>>plus wild cards, such as:
 >>>
 >>>+ .ccache/
 >>>- .ccache/**
 >>>
 >>>or:
 >>>
 >>>+ /cdrom/
 >>>- /cdrom/*
 >>>
 >>>I get either no directory or (directory + contents), but not (directory
 >>>- contents).  I have looked back from current till Oct. 02 but can not
 >>>find an example of anyone wanting to do this.




More information about the rsync mailing list