LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   having problems including only certain files in rsync (https://www.linuxquestions.org/questions/linux-general-1/having-problems-including-only-certain-files-in-rsync-622903/)

BrianK 02-21-2008 05:31 PM

having problems including only certain files in rsync
 
I'm trying to rsync only those files (and the dirs that contain them) that are in a directory called "1920x1080". That directory is in $source/foo/bar/1920x1080

I'm trying to rsync like so:
rsync -rptgoDLKvn --include="*1920*" $source $dest

... but it's still grabbing everything (the 'n' is in there for testing)

It should be known that many of the directories (including "1920x1080") in the path are symlinks that point to all sorts of different places (some pointing outside of the tree). I've managed to get them all acting like real dirs (hence the long option list, thanks LQ), but can't manage to get the include working. I don't want to use a filter rules file as the include will eventually come from user input.

any ideas?

slakmagik 02-23-2008 03:48 AM

Since this has come around a couple of times without response, I'll pitch in and say maybe you should restate your problem. First, it works for me - as near as I can figure.
Code:

:mkdir sys/rsyncdest sys/tmp/rsynctest

:touch sys/tmp/rsynctest/file

:rsync -avz --include='*rsynctest*' sys/tmp/rsynctest sys/rsyncdest/
building file list ... done
rsynctest/
rsynctest/file

sent 137 bytes  received 48 bytes  370.00 bytes/sec
total size is 0  speedup is 0.00

:ls -F sys/tmp/
rsynctest/  nfl.css  nfl.xml

:find sys/rsyncdest/
sys/rsyncdest/
sys/rsyncdest/rsynctest
sys/rsyncdest/rsynctest/file

Second, if you want to rsync '$source/foo/bar/1920x1080', then why not do 'rsync -avz $source/foo/bar/1920x1080 $dest'? And when you say "it's still grabbing everything", what is 'everything'? Everything in $source? And here the ground opens up: 'I don't want to use a filter rules file as the include will eventually come from user input.' So this is part of an interactive script for hapless users? Information about that would probably be important.

I'm not sure I can help because, while I swear by rsync and use it religiously, I just figured out what I wanted to do and put it in a script so I wouldn't have to think about it much again. :) The filters/include/exclude can be tricky, too.

BrianK 02-25-2008 12:42 PM

Quote:

Originally Posted by digiot (Post 3067034)
Since this has come around a couple of times without response, I'll pitch in and say maybe you should restate your problem. First, it works for me - as near as I can figure.

Thanks for the response. As a repeatable example, try this:
Code:

mkdir /tmp/rsynctest
touch !$/file1
mkdir ~/rtest
cd ~/rtest
mkdir source
mkdir dest
ln -s /tmp/ source/
ls -l source/ <shows the link in source to /tmp>
cd dest/
rsync -rptgoDLKv --include="*rsynctest*" ../source/ .
<notice - everything copied>

Quote:

Second, if you want to rsync '$source/foo/bar/1920x1080', then why not do 'rsync -avz $source/foo/bar/1920x1080 $dest'?
because 1920x1080 may exist in more than one place. While I could go in and find where it exists as a pre-process, I'd rather use the power rsync gives me by only including certain files. ;)
Quote:

And when you say "it's still grabbing everything", what is 'everything'? Everything in $source?
Yes, it's grabbing files/directories that do not match "1920", therefore the include is not working - at least in the example where there are lots of symbolic links.
Quote:

And here the ground opens up: 'I don't want to use a filter rules file as the include will eventually come from user input.' So this is part of an interactive script for hapless users? Information about that would probably be important.
I don't see why this is incredibly important, but yes, this is a script. It's meant for non-linux types that need to transfer data from a file server to their local machine. They run it by typing "localize 1920x1080" or "localize 640x486" or "localize some_thing"

Quote:

I'm not sure I can help because, while I swear by rsync and use it religiously, I just figured out what I wanted to do and put it in a script so I wouldn't have to think about it much again. :)
Well, thanks for the reply if nothing else. I use rsync all the time as well - just don't often use includes & even less often have to follow symlinks outside of the rsync'd tree.


All times are GMT -5. The time now is 05:10 PM.