Robocopy Download and Basic Usage (/MIR Backup)
Robocopy (Robust File Copy) is one of the best command-line tools for backing up and mirroring folders on Windows.
Where to get it: on Windows Vista, 7, 8, 10, 11 and Windows Server 2008 and later it’s built in — just open a command prompt and type robocopy. Nothing to download.
For old Windows XP and Windows Server 2003 it came with the Windows Server 2003 Resource Kit: download robocopy.exe for XP/2003.
Basic usage
Robocopy has lots of options, but this single line already keeps a mirror copy of a folder:
robocopy c:\Data1 d:\Data2 /MIR |
Careful with /MIR: it makes the destination an exact mirror — files deleted in the source are also deleted in the destination. Double-check the paths.
Useful options
robocopy C:\Data D:\Backup\Data /MIR /R:2 /W:5 /MT:8 /LOG:C:\backup.log |
/R:2 /W:5— retry a locked file twice, waiting 5 seconds (the default is a million retries!);/MT:8— copy in 8 threads (faster for many small files);/LOG:file— write a log instead of flooding the screen;/XD folder,/XF *.tmp— exclude folders or files;/L— dry run: only show what would be copied.
Put the command in a .cmd file and run it from Task Scheduler — and you have automatic backups.