[Gllug] rsync-ing sub-directories only

David L Neil DomainAdmin at GetAroundToIt.co.uk
Tue Nov 24 11:00:06 UTC 2009


Richard Jones wrote:
> On Mon, Nov 23, 2009 at 10:57:15AM +1300, GLLUG at getaroundtoit.co.uk wrote:
> [...]
> 
> I think what you want is:
> 
>   cd ~/Desktop
>   rsync -av --filter '+ /*/***' --filter '- *' . /path/to/target
> 
> Rich.


Rich,
(NB `pwd` must be Desktop)

rsync -rv --filter '+ /*/***' --filter '- *' . /junk

works perfectly, so I adapted it to cross my network and then used it 
'for real'...

Until I realised that I had used Firefox to File|SaveAs some web pages 
directly onto the Desktop (not part of a "project", in fact CmdLN 
HowTos!). These were then duly hoovered up by the rsync. Rats!

So I set about finding another exclusion. This seemed a logical 
extension of yours, but fails (regardless of case):
rsync -rv --filter '+ /*/***' --filter '- *_FILES' --filter '- *' . ~/junk
[code is all on one line, (my) email has word-wrapped]

So I tried extending by borrowing from my best effort (as below - no 
tittering from the back row please!), but it worked a little too well, 
and excludes any web pages saved within project file/sub-directories as 
well as those sitting on the Desktop - so is equally inappropriate:
rsync -rv --exclude='./*_files' --filter '+ /*/***' --filter '- *' . ~/junk

Any ideas please?

My fall-back position is either to borrow from Alain's suggestion and to 
set up an "Unsorted" or "Personal" directory which could then be 
excluded or `filter '-...'`-ed out; or to adapt my more long-winded script:

#!/bin/bash
clear
ls -F | grep / >rsynclink.tmp
rsync --files-from=rsynclink.tmp --exclude='*_FILES/' . ~/junk/ -rv
rm --force rsynclink.tmp

- which actually does cope with the necessary (FF) exclusion at only the 
Desktop level, and including those within sub-directories.

BTW: After re-reading `INFO rsync` I still haven't figured out your 
filter code - or is it RegEx?
Is there a limit to the depth of sub-directories it will cover?
(not that I anticipate a problem, merely curiosity)
Is it explained in the INFO - and thus I need to go back and read it 
more carefully, or is there some other source you could recommend please?
(I have started to comb O'Reilly's "Linux in a Nutshell" but will not 
have time today to start on van Vugt's "Beginning the Linux Command 
Line" eBook which covers some scripting in its final chapter)

Many thanks,
=dn
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list