I'm running something like the following: rsync -av -e "ssh" --include="dir1/***" --include="file1.txt" --exclude="*" superuser@remote-server:/var/www/ /var/, and all I'm getting is the following message:

receiving incremental file list

sent 276 bytes  received 10 bytes  21.19 bytes/sec
total size is 0  speedup is 0.00

And no files are transferring over.

  • Where is dir1 in relation to /var/www? What is it that you want to copy? At the moment you would copy the complete dir1 with contents, and the thing called file1.txt, but you would only do that if both dir1 and file1.txt was directly below /var/www.
    – Kusalananda
    Dec 6, 2018 at 21:13
  • dir1 would be at /var/www/dir1/; whereas, file1.txt, would be at /var/www/file1.txt. I want to copy the dir1 directory plus everything inside of it recursively. Plus I want file1.txt to be copied. And I want to exclude everything else.
    – Muskateer
    Dec 6, 2018 at 21:32
  • Can you show the output with -vvv set? That will have additional information about which items are included and excluded (and what the filters are set to).
    – BowlOfRed
    Dec 6, 2018 at 22:26
  • 1
    Are you sure the files are not already on the destination and up to date? My local tests show that your command should work, and that you get the output that you should get when no files need to be copied.
    – Kusalananda
    Dec 6, 2018 at 22:30

1 Answer 1


You are including subdirectories of dir1, but dir1 itself is excluded. So none of its children are seen.

From the rsync man page:

The concept [of] path exclusion is particularly important when using a trailing '*' rule. For instance, this won't work:

+ /some/path/this-file-will-not-be-found
+ /file-is-included
- * 

This fails because the parent directory "some" is excluded by the '*' rule, so rsync never visits any of the files in the "some" or "some/path" directories. One solution is to ask for all directories in the hierarchy to be included by using a single rule: "+ */" (put it somewhere before the "- *" rule), and perhaps use the --prune-empty-dirs option. Another solution is to add specific include rules for all the parent dirs that need to be visited. For instance, this set of rules works fine:

+ /some/
+ /some/path/
+ /some/path/this-file-is-found
+ /file-also-included
- *
  • I tried something like that following but it's copying everything instead of specific files and folders: rsync -av -e "ssh" --prune-empty-dirs --include="*/" --include="dir1/***" --include="file1.txt" --exclude="*" superuser@remote-server:/var/www/ /var/
    – Muskateer
    Dec 6, 2018 at 21:00
  • The dir/*** pattern will match the directory itself and its contents. This is not the issue.
    – Kusalananda
    Dec 6, 2018 at 21:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .