How to mirror only specified directories

Henri Shustak henri.shustak at
Fri Oct 1 04:53:33 MDT 2010

>> I'm still struggling to get just the directory(ies) that I want...
> You may find this <> post to the LBackup mailing list helpful. 
> The example listed (link above) revolves around specifying the root directory as the source and then specifying a selection of sub-directories to include in the sync and then finally a rule which will exclude everything else. 
> Please note that each directory within the path must specifically be included for this approach to work. IN addition, this approach utilizes only an excludes file (no include list via the command line).

Following up with the approach listed above, the excludes file quoted below should provide the results you are after if modified. Some minor modifications should be all that is required.

The example below (extract from URL above) is going to copy the directories /private and /home. It will transfer everything recursively within /private/etc/, /private/var/ and /home/

> + private     
> + private/etc/***
> + private/var/***
> + home/***
> - *

I understand you wanted to only transfer the /das/htdocs/docs/ directory and any contents within this directory recursively with rsync. Provided you are syncing the root directory then the following excludes file example listed below should make this happen : 

+ das
+ das/htdocs
+ das/htdocs/docs/***
- *

If you have other directories other than /das/htdocs/docs/ to transfer just add them in as required.

I think that reiterating the following is worth while : 

> read the man page.  ** and *** can be very useful.

Quoted from the rsync man page : 

> a  trailing  "dir_name/***" will match both the directory (as if
> "dir_name/" had been specified) and everything in the  directory
> (as  if  "dir_name/**"  had  been specified).  This behavior was
> added in version 2.6.7

I hope this helps.

This email is protected by LBackup, an open source backup solution. 
Free as in freedom; LBackup is licensed under the GNU

More information about the rsync mailing list