Using rsync filter to include specific, deep subdirectories under source path?

Dmt Ops opsdmt at
Thu Jan 30 11:22:07 MST 2014

I'm trying to get rsync filters working -- and understood.

My current, simple test script is


    ROPTS="--verbose --progress --itemize-changes \
     --recursive \
     --links \
     --perms \
     --times \
     --group \
     --owner \
     --devices \
     --specials \
      --acls \
      --xattrs \
    --human-readable \
    --numeric-ids \
    --relative \
    --delete-after \
    --delete-excluded \
    --iconv=UTF-8,UTF-8 \

    /usr/bin/rsync ${ROPTS} --filter="merge /home/test.filter"
root at /home/TEST

My 1st goal is to successfully filter to JUST backup "/boot", and all its
contents, give a SRC entry point of "/".

If I populate the filter file,

    cat << EOF >> /home/test.filter
    + boot/
    -sr /*

and exec the script, I end up with

    ls -1 /home/TEST

    du -h --max-depth=0 /home/TEST/boot/
        32M     /home/TEST/boot/

where the boot/ IS fully recursively populated with its files & subdir

So that works.

Next, I'd like to JUST backup two, specific subdirectories below /boot;
specifically /boot/grub & /boot/grub2.

Changing the filter If I add a file exclusion to the filter

    cat << EOF >> /home/test.filter
    + boot/grub/
    + boot/grub2/
    -sr /*

and re-exec the script, now, nothing is rsync'd -- no files or dirs are

Why doesn't the filter work for the subdirs?

How DO I filter to get just the subdirs of choice to rsync?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the rsync mailing list