robocopy D:\Temp\source D:\Temp\dest /MIR /XD "D:\Temp\dest\3" If I change the command to skip the destination folder instead then the folder is not deleted, when the folder is missing from the source. All is fine.īut, if I delete the source folder "d:\Temp\source\3" then the destination folder and the file are deleted even though it is on the skip list 1 D:\Temp\source\ If I run the command it is still fine, 4.txt stays there 3.txt is not copied over. Now add a folder to the destination to get this setup: d:\Temp\source\1.txt If I add /XD with the source folder and run the command it all seems good the command it wont copy it over. Let's add a new folder and then add it to the command to skip it.Ĭommand: robocopy D:\Temp\source D:\Temp\dest /MIR /XD "D:\Temp\source\3" This will copy over all the files and folders that are missing and deletes all the files and folders that cannot be found in the source Starting folder structure: d:\Temp\source\1.txtĬommand: robocopy D:\Temp\source D:\Temp\dest /MIR I will try to explain the different scenarios and what happens below, based on my experience.
EMCOPY EXAMPLES FULL
The solution is to add both the destination and the source folder with full path. The issue is that even though we add a folder to skip list it will be deleted if it does not exist. Hopefully I'm not overly confusing everyone here. So far I've tried and tested many other switches like /xo, /xx, but none of them solve my purpose.Īlso, /xx would work except that now it won't delete any folders at the destination at all and it wouldn't be mirroring. Need help and suggestions as to whether this is possible, and if it is then how can I do it.
So what I want to do is somehow use the /xd switch to avoid purging those subdirectories at the destination.Īlso, in the above example, in the /xd switch, I'm using the "*" wildcard to mean that I want to include all the directories that fall under the "\\hq04t3fis202\archive\dr" root folder at the destination. And at the destination, once these directories are mirrored from the source, there is another script which dumps separate subdirectories within each of those directories. In the above example, there are several directories under \\hq04t2fis202\archive\dr that are being mirrored.
Is there a way for me to use the /xd switch in robocopy wherein I'd be able to exclude the destination subdirectories.Įxample: robocopy "\\hq04t2fis202\archive\dr" "\\hq04t3fis202\archive\dr" /mir /xd "\\hq04t3fis202\archive\dr\*\hq04s2dba301" They are standalone subdirectories and I don't want them purged once the mirroring kicks in. The problem is that now there are going to be subdirectories within those folders at the destination which are not part of the original mirroring script. There is a script running which mirrors a bunch of folders from one volume to another.