Robocopy is still the best built-in way to copy a big folder on Windows, and /MIR keeps a backup folder identical to the source. Microsoft describes it as /e plus /purge, and that second half deletes files in the destination that aren’t in the source anymore. Mix up source and destination once and your backup copies an empty folder over your data.
So I always do a dry run first. /L only lists what would happen:
robocopy C:\Data D:\Backup /MIR /L
Read the list with care, above all the files it would remove from the destination. If the list looks right, run the same command without /L.
Two more switches I’d add for a real run:
robocopy C:\Data D:\Backup /MIR /R:2 /W:5 /LOG:C:\Logs\backup.log
The default is one million retries with 30 seconds between them, so one locked file can stall a copy for a very long time. /R:2 /W:5 keeps that short. /LOG writes the output to a file and overwrites it each time; use /LOG+ to append.
Caveat for scripts: robocopy’s exit codes aren’t the usual 0-is-good. Per the docs, 0 to 7 mean no failure (1 is files copied) and 8 or higher means at least one failure. A script that treats anything but 0 as an error will cry wolf every time.
Further reading: Microsoft Learn: robocopy