File server migration using Robocopy

I recently was tasked with moving one of our file servers from one physical server to another.  The file server had a bunch of files/directories with different permissions used by our finance/IT/Legal team. There are two things to keep in mind when it comes to permissions. There are NTFS permissions that the robocopy command will copy over and then there are the share level permissions which are not copied over with robocopy. The share permissions are stored in the registry, I manually entered the share level permissions on the destination.

Here is the command I used.

This command will mirror a D: drive on FS01 to the D: drive on FS02.
CAUTION: If destinaton has files that do not exist on the source, the destination files will be deleted (/MIR option).

robocopy \\FS01\d \\FS02\d /MIR /E /ZB /DCOPY:T /COPYALL /R:1 /W:1 /xd “$RECYCLE.BIN” “RECYCLER” “System Volume Information” /V /TEE /LOG:Robocopy4.log

\\FS01\d :: Source Directory (ie: “D:\My Music” or D:\ or \\server\d)
\\FS02\d :: Destination Dir
/MIR :: Mirrors Destination with source. If destinaton has files that do not exist on source the destinaton files are deleted.
/E :: copy subdirectories, including Empty ones.
/ZB :: use restartable mode; if access denied use Backup mode.
/DCOPY:T :: COPY Directory Timestamps.
/COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU). Copies the Data, Attributes, Timestamps, Ownser, Permissions and Auditing info
/R:n :: number of Retries on failed copies: default is 1 million.
/W:n :: Wait time between retries: default is 30 seconds.
/xd :: exclude the following paths
/V :: produce Verbose output, showing skipped files.
/TEE :: output to console window, as well as the log file.
/LOG:file :: output status to LOG file (overwrite existing log).

Other Robocopy commands:
Copies permissions, ACL, Timestamp, etc as above, but it does NOT mirror (/MIR). This command just copies from source to destination. So if certain files already exist on destination but don’t exit on source, robocopy will not touch them.

robocopy D:\ \\FS02\d /E /ZB /DCOPY:T /COPYALL /R:1 /W:1 /V /TEE /LOG:Robocopy1.log

This entry was posted in Microsoft, Scripting and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *