There is a script running which mirrors a bunch of folders from one volume to another. 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. They are standalone subdirectories and I don't want them purged once the mirroring kicks in. Is there a way for me to use the /xd
switch in robocopy wherein I'd be able to exclude the destination subdirectories.
Example:
robocopy "\\hq04t2fis202\archive\dr" "\\hq04t3fis202\archive\dr" /mir /xd "\\hq04t3fis202\archive\dr\*\hq04s2dba301"
In the above example, there are several directories under \\hq04t2fis202\archive\dr
that are being mirrored. 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. So what I want to do is somehow use the /xd switch to avoid purging those subdirectories at the destination. Also, 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.
Need help and suggestions as to whether this is possible, and if it is then how can I do it. So far I've tried and tested many other switches like /xo
, /xx
, but none of them solve my purpose. Also, /xx
would work except that now it won't delete any folders at the destination at all and it wouldn't be mirroring.
Hopefully I'm not overly confusing everyone here. Let me know if you have any questions.
The most basic use of robocopy is using a source and destination directory with no options. This option will copy all files (excluding subfolders) from C:\src to C:\dst. You can also copy everything including subfolders (empty or not) and NTFS permissions.
You can try to use the /XD parameter in order to exclude a directory based on a pattern. I've found that using /XD *. excludes directories with dots. I combine it with XA:SH in order to also exclude hidden files.
/MIR is an option to ROBOCOPY where you mirror a directory tree with all the subfolders including the empty directories and you purge files and folders on the destination server that no longer exists in source.
When i tried the solution with /XD i found, that the path to exclude should be the source path - not the destination.
e.g. this Works
robocopy c:\test\a c:\test\b /MIR /XD c:\test\a\leavethisdiralone\
Rather than creating empty directories in source to exclude, you can supply the full destination path to the /XD switch to have the destination directories untouched
robocopy "%SOURCE_PATH%" "%DEST_PATH%" /MIR /XD "%DEST_PATH%"\hq04s2dba301
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With