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
Here:
/E /A
will cause it to mirror directory structure from source locationd:\
to destination locationf:\d_backup
. It will create destination directory, if it does not exist./MT:4
will direct robocopy to use 4 thread to copy- helps saturate io bandwith./XD
is for excluding directory from source and/XF
is 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
Here:
/E
will copy directories recursively/XC
will exclude existing files with same timestamp, but different file sizes/XN
will exclude existing files with newer timestamp/XO
will 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 (click to expand..)