We help IT Professionals succeed at work.

Robocopy syntax

Hi all -

I need to migrate a large file share from one hard drive on my file server to another newly installed hard drive on the same file server.  My confusion and concern is 2-fold:

1.  This share has a ton of sub/sub-sub, etc, folders in it.  Some have no spaces in their names, but many DO have spaces in their names, so I'm struggling to figure out what the Robocopy syntax would be to migrate the whole share and account for this mix, without having to resort to doing each and every "main" subfolder in the root of the share one at a time.
2.   I've seen suggestions that incorporate the /MIR switch and suggestions that just do a "/E /CopyAll" without MIR.

The share is E:\IT and is an actual share and I want to copy it to F:\IT2, which is also an actual share with the same perms as the original E:\IT share.  Everything inside it is just a huge collection of non-shared, NTFS-secured folders, but with that usual mix of spaces and no-spaces in the names.

I have manually already created the new share, F:\IT2, shared it and set the share and NTFS perms to match E:\IT

Any guidance on what syntax I should use would be greatly appreciated.
Comment
Watch Question

Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:

ROBOCOPY won't have any problem with files or folders that have spaces in their names.  The only ones that matter are the starting folders you use in the command line, if those contain spaces themselves then place them in double quotes.  Since yours don't if you want to copy the folder tree just use E:\IT and F:\IT2.


/MIR makes the destination copy look exactly like the source folder tree, so if the destination already exists and has folders or files in it that are no longer in the source tree, they will be removed from the destination.  Any updated or new files will also be copied from source to destination.


/E will copy all new or updated files and folders, but won't remove any files or folders in the destination that don't exist in the source.


/COPY and /COPYALL affect what to copy, as shown in the help:


 /COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
                      (copyflags : D=Data, A=Attributes, T=Timestamps).
                      (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

/COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
Brett HartleySystems Administrator

Author

Commented:
I've seen suggestions that also use /COPYALL with /MIR.  Does that make sense?

This is the sytnax I've so far put together based on a bunch or research on forums...

robocopy E:\share\it\ F:\share2\IT2\ /e /zb /COPY:DATSO /MIR /r:1 /w:1 (I left off the "U" in /COPY:xxxxx" based on some people saying they've had issues copying the Audit info)
Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:

Yes.  /MIR (as well as /E and /S) controls what files and folders to select for copying.


Then /COPY specifies what to actually copy for each.  The default includes the data, attributes and timestamps.  But some additional security and info can also be specified if desired.

System Administrator
Distinguished Expert 2018
Commented:
This is what we use. Run from the destination server:

Initial copy:
robocopy.exe "\\old_fs\e$\Shares" "e:\Shares" /e /b /copyall /r:6 /w:5 /MT:64 /tee /log:c:\robocopylog.log /v

Open in new window


Final copy:
robocopy.exe "\\old_fs\h$\F" "h:\F" /mir /e /b /copyall /r:6 /w:5 /MT:64 /tee /log:c:\robocopylog.log /v

Open in new window