tl;dr: I want to rsync
a directory to its own descendant, and then rsync
the said descendant back to the original directory--including deletions and exclusions in both directions.
Before you ask the obvious question, "Why would you want to do that?" or point out how much better another approach would be, this is a business requirement. It's not my choice, and I'm aware of the risks, so just indulge me. I do not intend to justify the approach any further.
Details:
I want to rsync
a directory to its own descendant--i.e., a directory "underneath" or "inside" it, like parent
to parent/child
, for example--and then sync changes to the descendant back to the original directory, e.g., parent/child
to parent
, including deletions and exclusions in both directions. Visually, I need to do this:
parent -> parent/child
parent <- parent/child
The difficulties are to...
- Prevent infinite recursion when going from the ancestor to the descendant
- Not delete the source files mid-operation when syncing the descendant back to its ancestor (manifested as "file has vanished" errors)
- Respect the exclusions all the while