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

Kevin Korb kmk at sanitarium.net
Thu Jan 30 15:15:04 MST 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

First, don't use rsync without either --times or --archive.  Without
one of these rsync won't have any idea what is different the next time
it runs and it will re-copy everything.

As for the problem, if a directory is filtered then rsync will not
look inside of it to see if there are any not filtered things inside.
 Therefore, if you want to specify /boot/grub you need /boot too.

The other alternative (and easier way) to handle multiple directories
is to add --relative and list your directories instead of sources.

IOW: rsync ${ROPTS} --relative root at my.remote.com:/boot/grub/
root at my.remote.com:/boot/grub2/ /home/TEST

On 01/30/2014 01:22 PM, Dmt Ops wrote:
> I'm trying to get rsync filters working -- and understood.
> 
> My current, simple test script is
> 
> ---------------------------------------------- #!/bin/bash
> 
> 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 my.remote.com:/ /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 /* EOF
> 
> and exec the script, I end up with
> 
> ls -1 /home/TEST boot/
> 
> du -h --max-depth=0 /home/TEST/boot/ 32M     /home/TEST/boot/
> 
> where the boot/ IS fully recursively populated with its files &
> subdir contents.
> 
> 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 /* 
> EOF
> 
> and re-exec the script, now, nothing is rsync'd -- no files or dirs
> are transferred
> 
> Why doesn't the filter work for the subdirs?
> 
> How DO I filter to get just the subdirs of choice to rsync?
> 
> 
> 
> 

- -- 
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~
	Kevin Korb			Phone:    (407) 252-6853
	Systems Administrator		Internet:
	FutureQuest, Inc.		Kevin at FutureQuest.net  (work)
	Orlando, Florida		kmk at sanitarium.net (personal)
	Web page:			http://www.sanitarium.net/
	PGP public key available on web site.
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlLqzugACgkQVKC1jlbQAQdJ1QCglcwHInSeX8alhJ3HahCBWpdi
YXkAn0DUE+rHtj0U+MNeFJdpay/kB8c1
=cUiv
-----END PGP SIGNATURE-----


More information about the rsync mailing list