The Samba-Bugzilla – Bug 7629
Blank filter file option to ignore whole directory
Last modified: 2010-08-19 09:54:11 UTC
I know that there are external ways to do this, but I thought it would be fastest and best as an rsync feature. I've been using rsync for a while now in some fairly advanced backup schemes and I'm extremely impressed by it. I was thinking it would be quite helpful if there were an option to ignore directories with a certain file in them, say .ignore-backup or .ignore-rsync. This would make for an easy way to avoid copying excess data, whether it be extracted source tarballs, or existing backups.
I know that rsync supports filter files of a certain name, but I'd like an option where if it sees the file and it's blank, it simply skips the directory.
So for example:
/home/user/backup/.ignore-rsync exists and is blank, then /home/user/backup is ignored, but the it continues onto other folders. If it has filter rules in it, it can continue with processing those rules.
Let me know what you think. I believe it would be a very helpful and simple feature to add.
The easiest way to accomplish this is to make that signal file be name .rsync-filter, put "- *" into it, and use the -F option for the copy. Rsync will then obey any filter rules it encounters in the .rsync-filter files it finds sprinkled around in the hierarchy. This idiom will leave an empty directory, though. If you want to avoid that, you'd need to put "- /dirname" into the .rsync-filter file of the parent directory (the slash anchors the exclude in the current directory so it doesn't filter a similarly named file/dir in another directory). If you want to hide the parent-dir .rsync-fiter files, you can repeat the -F option.