Mirror folders with robocopy for exact backups

Robocopy is Windows' built-in robust file copier: use /MIR to keep a destination folder as an exact one-way mirror of a source, resumable and restartable.

WindowsFilessystemTerminalHigh risk
Run `robocopy "C:\Data" "E:\Backup\Data" /MIR /R:2 /W:5` to mirror the source to the destination — mind that /MIR deletes extra files in the destination.

01Command

Command
$ robocopy "C:\Data" "E:\Backup\Data" /MIR /R:2 /W:5 /DCOPY:DAT /COPY:DAT

02What it does

/MIR equals /E (copy all subfolders including empty ones) plus /PURGE (delete destination files that vanished from the source), making the destination an exact copy. /R:2 /W:5 caps retries at 2 with a 5-second wait so locked files don't hang the job for days, and /COPY:DAT /DCOPY:DAT preserve timestamps and attributes on files and directories. Robocopy is multithreaded with /MT:8 or higher and restartable — rerunning the same command resumes where it left off. Check the exit code table: 0 means nothing copied, 1 means files copied successfully, and 8+ means failures (log them with /LOG:path and /TEE).

03Risk

RiskHigh risk
RequirementsDestination must exist or be creatable; deleted files in the source will also be deleted in the destination.
!Warning: /MIR is destructive: if you swap the source and destination paths by mistake it will wipe the destination — test with /L (list only) first.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • robocopy | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents robocopy /MIR as mirroring a directory tree, copying all subdirectories including empty ones and deleting destination files no longer present in the source.
  • Robocopy - Robust File Copy - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: SS64 documents /COPY:DAT as copying data, attributes and timestamps, and /R and /W as retry count and wait time between retries.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions