Working with Rsync includes and excludes can feel like you have two opposing forces in their respective corners of the boxing ring, with you in the middle getting hammered. To bring harmony to the ring we'll walk through an example of including a subsection of an directory tree that is marked by Rsync for exclusion.
We have a Utils directory tree that we don't want to backup, so we're marking the entire directory for exclusion. We do however want to backup the Utils/Solr-4.7.0/home subdirectory and all of its contents.
We're going to use Grsync, cause it's a sweet GUI front-end for Rsync. Here are the advanced options we'll use for the backup, which will serve as the command line options for Rsync. Remember to place the –include-from before exclusion processing.
In order to include selected subdirectories and their contents (an all recursive tree and nothing else), we'll need several rules in our Includes file.
Now we can list utils in our excludes file where you'll see it about half-way down the list. No slash or asterisks required. Another tip which might prove helpful is to remember that rsync processes includes and files listed by their relative position from source directory.
As we see in the rsync output, our Solr-4.7.0/home directory area is backed-up and while you'll have to trust me on it, nothing else in the /utils area is touched.