I've been using rsync to clone my Windows user profile to a remote server on a nightly basis. I'm using a
--filter='merge <file>' arg to load a file full of include/exclude rules, which I use to avoid transferring browser caches and other stuff that I know is useless. I'm also using the
--prune-empty-dirs to avoid creating a bunch of unnecessary empty directories.
My script also uses the
--delete-excluded switch, because that way if I identify more stuff that I want to exclude, I can just add it to the filter file, and it will automagically get nuked the next time the job runs.
However, this has the side effect of deleting all empty directories. I'm worried that this will break something in the case of a poorly written app that doesn't check for directory existence before writing data.
Is there a way to "prune" only those directories that are empty as a result of exclusions, and not directories that are actually empty on the source side? (I'd like to do this with a simple rule, rather than having to explicitly give any dirs by name, because of the number of dirs involved.)
The only workarounds that immediately come to mind are:
- stop using
--prune-empty-dirs, and live with the extra directories.
- stop using
--delete-excludedin the nightly job, and manually run
--prune) whenever I change the filter file, which will nuke the new excludes and re-create the "genuinely" empty dirs. Neither is ideal.