Currently, when rsync searches for a basis file in an alternate basis directory specified with a --*-dest option, it blindly follows the file-list path from the top of the alternate basis directory. This might be the wrong thing to do if the basis directory contains symlinks. The script that I will soon attach demonstrates how rsync's behavior might result in a corrupt backup. I propose that rsync should obey the --keep-dirlinks setting when searching for basis files. If --keep-dirlinks is disabled, rsync would have to lstat every proper prefix of the path under the basis dir to make sure symlinks are not accidentally being followed. For efficiency, this check should be done only once per directory. It would fit nicely in the per-directory initialization, near line 911 of generator.c.
Created attachment 2098 [details] Script for a backup scenario that tickles the bug
Note that, in the absence of a proper fix for this issue, symlink munging in the destination can prevent surprises like the one seen in comment #1.