robocopy is a pretty good cmd utility to copy/mirror directories. I have been using it regularly now. One of the recent usages was to backup data.
robocopy /E /A /MT:4 d:\ f:\d_backup /XD d:\OneDrive /XF d:\pagefile.sys
/E /Awill cause it to mirror directory structure from source location
d:\to destination location
f:\d_backup. It will create destination directory, if it does not exist.
/MT:4will direct robocopy to use 4 thread to copy- helps saturate io bandwith.
/XDis for excluding directory from source and
/XFis for excluding files from source. One can provide many locations and files- just that these need to come after source and destination locations. The entries for exclusion can be regex as well.
Similarly to just copy without overwriting anything:
robocopy <src> <dst> /E /XC /XN /XO
/Ewill copy directories recursively
/XCwill exclude existing files with same timestamp, but different file sizes
/XNwill exclude existing files with newer timestamp
/XOwill exclude existing files with older timestamp
One thing I noticed is that, due to a certain bug, if
robocopy creates the destination directory- it might create it hidden. It won’t show in explorer, but will be there if you go to that path. The simplest way to fix is to reset the attributes on this destination directory.
attrib -s -h f:\d_backup
links of interest: