Windows - Robocopy File Mirrors and Backups
Published: Windows Estimated reading time: ~2 minutes
Using the /MIR
switch
Copy all files, replacing files in the destination or deleting files in the destination that are not in the source folder.
Copy without any permissions.
robocopy "\\MySource\Folder" "\\MyDestination\Folder" /MIR /r:1 /w:1 /copy:DAT /xf *.pst Thumbs.db /np /tee /log:c:\roboCopy.log
/MIR Mirrors a directory tree (equivalent to /e plus /purge). The /mir option is equivalent to the /e plus /purge options with one small difference in behavior: With the /e plus /purge options, if the destination directory exists, the destination directory security settings are not overwritten. With the /mir option, if the destination directory exists, the destination directory security settings are overwritten.
/R:1 Try to copy one additional time if a file copy fails.
/W:3 Wait 3 seconds before re-trying a copy due to a failure.
/log:"i:/log.txt" Save the log to a file.
/v Produces verbose output, and shows all skipped files.
/tee Output to console window, as well as the log file.
/ETA Show Estimated Time of Arrival of copied files. (Don't use this with /log)
/XF Exclude files. In this example, thumbs.db and any .pst files will NOT be copied.
Backup
robocopy "D:\FolderMyStuff" "\\DestinationServer\Share" /MIR /FFT /R:3 /W:10 /Z /NP
/FFT Assumes FAT file times (two-second precision) This option allows a 2-second difference when comparing timestamps of files. Files with time discrepencies of < 2 sec are considered to be unmodified as long as the rest of the file attributes are the same. Without this option, an unmodified file in the source folder could have a slightly different timestamp than the file in the destination folder and would needlessly be copied.
/Z Copies files in Restart mode This means that if file is interrupted during copy, robocopy will pick up where it left off rather than re-copying the entire file.
/NP Specifies that the progress of the copying operation (the number of files or directories copied so far) will not be displayed.