Linux – rsync –files-from specifies folders but does not copy files, recursive does not fix it

linuxrsync

I've just recently revisited a script that I maintained a few years back and trying to get it to work on a new server.

It basically runs the following

rsync -vaP --copy-unsafe-links --files-from=dirlist.txt --exclude-from=excludelist.txt . /path/to/backup

dirlist.txt is a plain text file that contains directories with files I want synced relative to .

foo/
foo/bar
foo/bar/gop
foo/tra
foo/bla
foo/bla/rgh
foo/bla/rgh/meh

and excludelist.txt is a plain text file that contains the path to specific files within the above directories that I want to exclude from the rsync command.

When I run the above I get

/path/to/backup/foo
/path/to/backup/foo/bar
/path/to/backup/foo/bar/gop
/path/to/backup/foo/tra
/path/to/backup/foo/bla
/path/to/backup/foo/bla/rgh
/path/to/backup/foo/bla/rgh/meh

But none of the files that were in the source directory were copied over?

I've tried using the -r command but then I end up getting directories that I don't want like foo/don or foo/tco copied when it runs the rsync for foo/.

I know this script has run in the past so I'm very confused as to what has changed (other then maybe the rsync version but I can't track down the version I had last ran on).

Update:
I'm using various versions of rsync from 2.5.7 to 2.6.6. In 2.5.7 it doesn't have –files-from nor –Filter

Best Answer

I had a similar problem a while ago.

My solution was to opt for the filter rule as follows:

rsync --archive -r --filter="merge fromfile" --dry-run

fromfile
- /el[2-4]*
- "*/ppc/*"
+ /el5
- /*

This excludes any sub directories named ppc, any top level directories el2, el3, el4, includes el5 and excludes everything else.