-   Linux - Software (
-   -   rsync syntax to skip directory, but copy select files.. (

tnicol 05-11-2004 09:34 AM

rsync syntax to skip directory, but copy select files..
I'm trying to use rsync to backup from one drive to another. I'm having trouble with the syntax to skip a folder except for certain file extensions in that folder. No combination of --exclude, --include, --exclude-from, or --include-from seems to be able to handle it. I either get all of the folder I'm trying to skip or none of it. Any ideas?

homey 05-11-2004 10:02 AM

This should work.....

Where test is the directory you want to exclude and
*.txt are the files that you want to include.

--include "test/*.txt" --exclude "test/"

tnicol 05-11-2004 08:25 PM

Thanks, but --include "test/*.txt" --exclude "test/" doesn't do the trick. Nothing in directory "test" gets copied as long as the --exclude is there, even with the explicit --include of the files. Any other ideas?

gloriant 07-24-2007 06:40 AM

This problem can be solved thus:

rsync -av '--include=test/*.txt' '--exclude=test/*' startdir/ targetdir/
the solution proposed by homey excluded test/ directory, while this only excludes the files in test directory.

I now still see a problem with the .txt-files in subdirectories of test...
Anybody ?

All times are GMT -5. The time now is 10:45 AM.