Robocopy Command to Retain All Permissions
Here’s the command I typically use when I want to retain all permissions, ownership and timestamps of the entire folder structure and data:
robocopy source destination /E /ZB /DCOPY:T /COPYALL /R:1 /W:1 /V /TEE /LOG:Robocopy.log
Here’s what the switches mean:
- source - source directory (drive:\path or \server\share\path)
- destination - destination directory (drive:\path or \server\share\path).
- /E - copy sub-directories, including empty ones.
- /ZB - use restart-able 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, owner, permissions and auditing info
- /R:n - number of Retries on failed copies: default is 1 million but I set the example above to only retry once.
- /W:n - wait time between retries: default is 30 seconds but I set the example above to 1 second.
- /V - produce verbose output, showing skipped files.
- /TEE - output to console window, as well as the log file.