6

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.

The /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.

Any hints?

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 XCOPY's /B).

6
  • Sorry, but I don't see it as a bug. You're telling it to mirror it, or to eliminate (purge) the contents on the TARGETDIR that are not present on the SOURCEDIR. So, if the symlink does not exist on the SOURCEDIR, it'll delete it on the TARGETDIR. If you don't want that, don't use /MIR ou /PURGE. Or use another directory as the TARGETDIR. Also, with the information given so far, what you're expecting is unlogical. Mar 18, 2013 at 18:28
  • 4
    Again, it does not delete the symlink, it deletes everything the symlink points to. At least should /XJ prevent this. Note that DEL, RMDIR and the Explorer have been made safe against symlinks, i.e. will not follow symlinks when deleting them. Mar 18, 2013 at 18:32
  • Sorry, but I disagree. /XJ does what seems logical (to me). It ignores Junction Points on the SOURCEDIR, not on the TARGETDIR. Specially with the /MIR and /PURGE. Take a look at TeraCopy and see it does what you need. Mar 18, 2013 at 18:39
  • 2
    Found ROBOCOPY /SL option which copies symlinks. Feb 4, 2014 at 8:10
  • @AndreasSpindler Found a solution yet? I don't think will fix it: /SL follows the symbolic link and copies the target.
    – RvdK
    Feb 22, 2019 at 8:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.