Craig Hammond
2006-Feb-09 06:46 UTC
exclude an excluded file from being deleted by --delete-excluded
Hi, I have a particular directory in my exclude list, but I want it excluded from --delete-excluded. Is this possible. or maybe if I explain what I'm trying to do, someone will come up with a more suitable way. I am using rsync (2.6.6) to backup data from a Windows Server (cygwin) to an OpenBSD box. rsync -rtvz --delete-excluded --del --timeout=3600 -e "ssh -i c:\cygwin\ssh-key" --exclude-from=/cygdrive/d/rsync/rsync-d-exclude.txt --bwlimit=5 /cygdrive/d user@rsync.example.net.au:/var/rsync/user/backup/server So basically, I'm backing up the whole D: drive of the windows server except for what I exclude. I run this at about 6pm to capture all the data from the days work. One of the directories I exclude has a database in it as it is always still in use at this time. At about 2am, I run another instance of rsync to copy just the directory containing the database. My problem is that as the database directory is in the exclude list, it gets deleted because of the --delete-excluded. I do however want the --delete-excluded active for the remainder of the directories. Thanks, Craig.
Wayne Davison
2006-Feb-09 09:46 UTC
exclude an excluded file from being deleted by --delete-excluded
On Thu, Feb 09, 2006 at 05:35:11PM +1100, Craig Hammond wrote:> I have a particular directory in my exclude list, but I want it > excluded from --delete-excluded.Sure, that's easy enough using filter rules. Just add a protect filter rule to what you have now and rsync will protect any matching files from deletion: -f "protect /db/dir/" If you aren't familiar with filter rules, you can think of a normal exclude as having two filter effects: it hides files on the sending side, and it protects files from deletion on the receiving side. Using the --delete-excluded option turns off the protect feature of normal excludes, but it has no effect on other filter rules, such as an explicit protect. While you're at it, I'd recommend switching your excludes over to hide rules, which allows you to put all your rules into a single file and to get rid of the --delete-excluded option. For example, imagine these lines in a file: H /unneeded/dir/ H *.trash P /db/dir/ - /hide/and/protect/ The "H" is the short way to specify "hide", "P" is short for "protect", and "-" (short for "exclude") does both. If you need to specify the opposite of a hide, see the "show" (S) filter rule. You then use a --filter (-f) option to read the above file instead of using --exclude-from: rsync -av -f ". /some/filter-file" --del src/ dest/ The "." is the merge rule that reads in the contents of the specified file (yes, you can merge a filter file from inside another filter file). ..wayne..