Stuart Anderson
2008-May-27 06:31 UTC
How to exclude directories from source with --relative
I have been unable to figure out how to exclude directories that only exist on the source side when running rsync version 3.0.2 with --relative. Here is an artificial test that shows my problem in case 3). Any help would be appreciated. # mkdir -p /tmp/source/a/b /tmp/source/a/c # touch /tmp/source/a/b/hello /tmp/source/a/c/world 1) Try mirroring both b/ and c/, this works: # rsync -avn --relative /tmp/source/./a/? /tmp/destination sending incremental file list created directory /tmp/destination a/ a/b/ a/b/hello a/c/ a/c/world sent 119 bytes received 30 bytes 298.00 bytes/sec total size is 0 speedup is 0.00 (DRY RUN) 2) Try excluding b/, this works: # rsync -avn --relative --exclude b/ /tmp/source/./a/? /tmp/destination sending incremental file list created directory /tmp/destination a/ a/c/ a/c/world sent 76 bytes received 23 bytes 198.00 bytes/sec total size is 0 speedup is 0.00 (DRY RUN) 3) Try excluding a/, this does not work: # rsync -avn --relative --exclude a/ /tmp/source/./a/? /tmp/destination sending incremental file list created directory /tmp/destination a/ a/b/ a/b/hello a/c/ a/c/world sent 119 bytes received 30 bytes 298.00 bytes/sec total size is 0 speedup is 0.00 (DRY RUN) -- Stuart Anderson anderson@ligo.caltech.edu ligo.caltech.edu/~anderson
Wayne Davison
2008-May-27 06:39 UTC
How to exclude directories from source with --relative
On Mon, May 26, 2008 at 09:46:04PM -0700, Stuart Anderson wrote:> # rsync -avn --relative --exclude b/ /tmp/source/./a/? /tmp/destinationThat excludes all "b" dirs. It's safer to exclude "/a/b/" (anchored and fully specified). The simple rule is to exclude the names that rsync outputs via -v.> 3) Try excluding a/, this does not work: > > # rsync -avn --relative --exclude a/ /tmp/source/./a/? /tmp/destinationThat's because 'a' is an implied directory in the longer path that you told rsync to transfer. Implied directories can't be excluded, but their attributes can be omitted via --no-implied-dirs. If you don't want it in the transfer, don't specify it (and if you're using wild- cards, specify them in such as way as to avoid matching the dir you don't want). ..wayne..