Let's say we have a folder
SOURCEDIR to be synchronized with
TARGETDIR. The problem: if
TARGETDIR contains directory symlinks,
ROBOCOPY /MIR (or
/PURGE) will follow the symlink, and delete every file and directory it points to.
/XJ option does not work for
TARGETDIR. Also there is no difference in using directory symlinks or junctions; both are followed and deleted. This seems to be a serious bug, especially if we said
/XJ. As soon as the target directory contains symlinks the copying operation can "escape" the directory boundaries, and more files and folders than intended go over board.
P.S.: For example,
ROBOCOPY sync'd part of
TARGETDIR, stumbled over a symlink, deletes parts of
TARGETDIR again, then continued as if nothing happened. Finally you got a damaged
TARGETDIR - probably without noticing. There is nothing you can do against it. But symlinks are a normal part of the file system. IMHO there should be an option to remove but not follow symlinks (like
/XJprevent this. Note that
RMDIRand the Explorer have been made safe against symlinks, i.e. will not follow symlinks when deleting them.