A few weeks ago I wrote about using XCopy to copy files and folder structures including their NTFS Permissions. Recently I came to the point where I wanted to see all errors and their related files, so I could fix messed up NTFS permissions. With XCopy however parsing the log is pretty much impossible. Also Microsoft suggests using RoboCopy as a sucessor to XCopy. And thats what I did.

Using RoboCopy like XCopy

In my other blog post I meantioned that I wanted to copy all folders and files including their NTFS permissions and ignore errors on the way. You can do the same thing with RoboCopy and it is a lot faster.

To achieve the same result you can use the following command to keep directories in sync.

1
ROBOCOPY S:\Source_Dir D:\Destination_Dir /MIR /SECFIX /COPYALL /R:0 /W:0 /LOG:"C:\Logs\example_$(get-date -f "yyyy-MM-dd_hh-mm-ss").log" /TEE

Okay let’s go over the switches line by line.

ParameterDescription
/MIRMirrors the source to the destination dir copying all files and folders, including empty ones.
/SECFIXFixes security permissions on already copied files (you can leave this out if you want)
/COPYALLCopies all files attributes including NTFS permissions.
/R:0Number of times to retry copying a failed file.
/W:0Wait time between retries. Defaults to 30 seconds.
/LOG:fileLogs output into the givenfile.
/TEELogs output to console and logfile.

You can always see a full list of switches with /?.

Parsing RoboCopy error log

With RoboCopy we now get parseable log files and can use this nifty script from the Technet Gallery to extract all failed files from the logs.