SRC=/, include a few directories and exclude everything else

Matt McCutchen hashproduct at
Tue Dec 6 21:58:53 GMT 2005

On Tue, 2005-12-06 at 13:36 -0500, H.S. wrote:
> + */
> + Documents and Setting/WinUser/My Documents
> + Documents and Setting/WinUser/Start Menu/
> + Documents and Setting/WinUser/Recent/
> + Documents and Setting/WinUser/Application Data/Mozilla/
> + Documents and Setting/WinUser/Application Data/Thunderbird/
> - *
> The idea is to backup only the directories mentioned above, and leave
> everything else out. But given these rules, nothing is backed up.

The five "Documents..." rules are only including those directories, not
the files inside.  Try this:

+ */
+ Documents and Setting/WinUser/My Documents/**
+ Documents and Setting/WinUser/Start Menu/**
+ Documents and Setting/WinUser/Recent/**
+ Documents and Setting/WinUser/Application Data/Mozilla/**
+ Documents and Setting/WinUser/Application Data/Thunderbird/**
- *

The first rule includes all directories, and the next five include all
the files recursively inside the five directories you want.  If you
don't like getting a thicket of directories in addition to the five
trees you want, you can do something like this:

        + Documents and Setting
        + Documents and Setting/WinUser
        + Documents and Setting/WinUser/My Documents
        + Documents and Setting/WinUser/My Documents/**

Note that this matches each parent directory individually and then
matches all the files in the tree.

However, instead of using filters, it might be easier to collect the
directories using --relative.  Consider this command:

        cd / && rsync --relative "Documents and Setting/WinUser/"{"My
        Documents","Start Menu","Recent","Application
        Data/Mozilla","Application Data/Thunderbird"} backup/
This will create "/backup/Documents and Setting/WinUser/My Documents"
and so forth.
Matt McCutchen, ``hashproduct''
hashproduct at --

More information about the rsync mailing list