Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Robocopy’s /MIR switch can delete files and folders from the destination. Microsoft defines /MIR as /E plus /PURGE: it makes the destination match the source by removing destination items that are missing from the source. To avoid surprises, verify both paths, preview the operation with /L, inspect the log, and only then remove /L for the real run. If destination-only files must be retained, use /E instead of /MIR, with /XX where appropriate.

What Robocopy /MIR really does

Robocopy is built into Windows and copies files and directory trees from a source path to a destination path. The command’s direction matters: the first path is the source, and the second is the destination.

/MIR means “mirror.” Microsoft documents it as equivalent to /E plus /PURGE. /E copies all subdirectories, including empty ones. /PURGE deletes destination files and directories that no longer exist in the source. Therefore, a mirror is not a protected backup: a file that exists only in the destination is a candidate for deletion when the command runs. See Microsoft’s Robocopy command reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, if D:Backupold-report.docx is absent from C:Source, a real /MIR run can remove the copy in D:Backup. That is the intended behavior for an exact mirror, but it is dangerous when the destination also contains archival files, independently edited documents, or earlier backup versions.

#1 Best Overall
WD 2TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBYVG0020BBK-WESN
  • Slim durable design to help take your important files with you
  • Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
  • Back up smarter with included device management software[2] with defense against ransomware
  • Help secure your important files with password protection and hardware encryption
  • 3-year limited warranty

The word “mirror” describes synchronization, not historical retention. If a file is deleted from the source and you run /MIR, the corresponding destination copy is normally treated as an extra and removed. If a file is renamed, the old name can be purged and the new name copied. A mirror therefore preserves the current shape of one tree; it does not preserve every earlier state of that tree.

Does Robocopy /MIR delete files?

Yes. It can delete files and directories from the destination when they are absent from the source. The deletion applies to destination-only items within the scope of the command, including items that were placed there independently of the source. It does not mean Robocopy deletes every destination file: files that correspond to source items are copied or updated according to their differences, while extras are the items targeted by purge behavior.

That distinction is why the source and destination must be identified before execution. If the paths are reversed, the wrong folder becomes authoritative. With /MIR, that mistake can make the intended source tree look like destination-only content and expose it to deletion.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The safe mirror workflow

Use this process whenever deletion at the destination would be costly.

  1. Identify the authoritative folder. Write down the complete source and destination paths. Decide which location contains the files that should win if the two trees differ. Do not assume that a path copied from an example applies to your computer.
  2. Check the destination’s contents. Open the destination in File Explorer or list it from the command line. Identify any destination-only files or folders that must survive. If any must remain, plan to use a non-purging command rather than /MIR.
  3. Preview the mirror. Add /L to the intended command and write the output to a log. For example:
robocopy "C:Source" "D:Backup" /MIR /L /LOG:"C:LogsRobocopy-preview.log"

Replace every example path with a real path from your environment. Check quotation marks, drive letters, spelling, and the location where the log will be written. Quoting is especially important for paths containing spaces.

  1. Read both the console output and the log. Confirm that Robocopy identifies the expected source and destination roots. Look specifically for destination-only files and directories that the preview says would be removed. Check exclusions as well; an excluded item will not participate in the copy or mirror operation.
  2. Change the command if the plan is wrong. If anything that must be retained is listed for deletion, remove /MIR and use a copy-oriented command such as /E, optionally with /XX. Preview that revised command again.
  3. Run only after the preview is acceptable. Remove /L, retain a log switch, and execute the command from an account with the required access to both locations.
  4. Review completion status. Keep the log and interpret Robocopy’s return code. A code of 8 or higher indicates that at least one failure occurred, even if many files were copied successfully.

/L is a list-only mode. Microsoft states that, with /L, files are not copied, deleted, or timestamped. It is a preview of the planned operation, not a backup and not a rollback mechanism. Remove it only after the displayed changes are understood. Microsoft also describes logging as a way to review integrity after the run; see the Azure Files Robocopy migration guidance.

Run the preview against the same paths, switches, exclusions, and log location you intend to use for the real operation. Changing a switch after reviewing the preview can change the plan. A preview made with /E, for example, does not prove what a later command using /MIR will delete.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Kosbees 500 GB External Hard Drives,Portable Hard Drive for Windows,Ultra Slim External HDD Store Compatible with PC, MAC,Laptop,PS4, Xbox one, Xbox 360;Plug and Play Ready
  • 【Plug-and-Play Expandability】 With no software to install, just plug it in and the drive is ready to use in Windows(For Mac,first format the drive and select the ExFat format.
  • 【Fast Data Transfers 】The external hard drives with the USB 3.0 cable to provide super fast transfer speed. The theoretical read speed is as high as 110MB/s-133MB/s, and the write speed is as high as 103MB/s.
  • 【High capacity in a small enclosure 】The small, lightweight design offers up to 500GB capacity, offering ample space for storing large files, multimedia content, and backups with ease. Weighing only 0.35 Lbs, it's easy to carry "
  • 【Wide Compatibility】Supports PS4 5/xbox one/Windows/Linux/Mac and other operating systems, ensuring seamless integration with game consoles,various laptops and desktops .
  • Important Notes for PS/Xbox Gaming Devices: You can play last-gen games (PS4 / Xbox One) directly from an external hard drive. However, to play current-gen games (PS5 / Xbox Series X|S), you must copy them to the console's internal SSD first. The external drive is great for keeping your library on hand, but it can't run the new games.

Choosing a command that matches your goal

Goal Typical switches Effect on destination-only items Use when
Exact directory-tree mirror /MIR Can delete them The destination must match the source and removals are intentional.
Recursive copy/update /E Retains them by itself You want subdirectories, including empty ones, copied without adding purge behavior.
Copy while explicitly excluding extras from deletion /E /XX Excludes destination-only files and directories from deletion You want recursive copying but cannot allow a strict mirror.
Preview any of the above Add /L No files are copied or deleted You need to inspect the plan before making changes.

/XX changes the result from an exact mirror: destination extras are excluded rather than removed. Microsoft’s reference specifies that excluded extra files are not deleted. Do not call an /E /XX result a strict mirror, because the destination may contain content absent from the source.

/E and /MIR are often confused because both recurse through subdirectories. The difference is purge behavior. /E adds directories, including empty ones, and updates files without itself requesting deletion of destination extras. /MIR adds that deletion behavior through /PURGE. Choose based on whether the destination is a disposable replica or a location that accumulates independent content.

Preview commands you can adapt

Preview an exact mirror

robocopy "C:Source" "D:Backup" /MIR /L /LOG:"C:LogsRobocopy-preview.log"

This lists additions, updates, mismatches, and destination items that the real mirror would purge. It does not make those changes while /L is present.

Preview a non-purging recursive copy

robocopy "C:Source" "D:Backup" /E /L /LOG:"C:LogsRobocopy-preview.log"

This copies the tree recursively when run without /L, including empty directories, but /E alone does not invoke purge. Existing destination-only content is not targeted for deletion by that switch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run the approved mirror and keep a permanent log

robocopy "C:Source" "D:Backup" /MIR /LOG:"C:LogsRobocopy-run.log"

Use /LOG+: instead of /LOG: when you want to append to an existing log rather than overwrite it:

robocopy "C:Source" "D:Backup" /MIR /LOG+:"C:LogsRobocopy-history.log"

These are syntax templates, not universally safe commands. The correct paths, permissions, exclusions, filesystem behavior, and retention policy depend on your environment. A separate physical drive can be used as a destination, and Microsoft also documents Robocopy workflows for Azure Files, but neither a second drive nor cloud storage changes what /MIR does when aimed at that destination.

How to read Robocopy’s return codes

Robocopy’s exit code is not a simple “zero means good, nonzero means bad” scheme. Codes below 8 describe combinations of copying, mismatches, and extra items; codes 8 and above indicate at least one failure.

Rank #3
WD 4TB My Passport, Portable External Hard Drive, Black, Backup Software with Defense Against ransomware, and Password Protection, USB 3.1/USB 3.0 Compatible - WDBPKJ0040BBK-WESN
  • Slim durable design to help take your important files with you
  • Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
  • Back up smarter with included device management software[2] with defense against ransomware
  • Help secure your important files with password protection and hardware encryption
  • 3-year limited warranty
Code Microsoft’s documented meaning What to do
0 No files were copied, and there was no failure or mismatch. Confirm that an already synchronized tree was expected.
1 All files copied successfully. Review the log for the files changed.
2 Destination has extra files or directories. Decide whether extras are acceptable or indicate an incorrect source, destination, or switch choice.
3 Files were copied and destination extras exist. Check whether the extras should remain.
5 Files were copied and mismatches exist. Investigate mismatched attributes, timestamps, or content as appropriate.
6 Extras and mismatches exist, but no files were copied. Review the log and determine whether the differences are intentional.
7 Files were copied, with mismatches and extras. Review all listed differences before treating the run as complete.
8 or higher At least one failure occurred. Treat the run as unsuccessful until the log identifies and the failed items are addressed.

Interpret the code together with the command’s purpose. For example, a code reporting extras may be expected during a non-purging copy, while the same result may signal that an exact mirror was not achieved. Automation should generally treat 8 or higher as a failure condition, while recording lower codes for later review rather than assuming every nonzero value is an error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Limit the operation with exclusions

Robocopy can narrow the scope, but every exclusion also means that content is intentionally omitted from the operation. Preview exclusions before a real run.

  • /XD excludes matching directories.
  • /XF excludes matching files.
  • /XJ excludes junction points. Junctions are normally included by default, so this switch can prevent traversal into linked directory locations.

For example, a preview that excludes a cache directory and temporary files could look like this:

robocopy "C:Source" "D:Backup" /MIR /XD "C:SourceCache" /XF "*.tmp" /XJ /L /LOG:"C:LogsRobocopy-preview.log"

Check that each exclusion matches what you intend. Excluded files are not copied or updated, and excluded directories are not mirrored. If the destination contains an old excluded copy, do not assume a later mirror will remove or refresh it. A broad wildcard such as *.tmp can affect files in every traversed directory, not just one folder.

Control retries and waiting instead of relying on defaults

Robocopy’s documented defaults are a retry count of 1,000,000 and a 30-second wait between retries. Those settings affect how long the command can remain stuck on an unavailable or locked item; they do not make deletion safer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set deliberate limits for unattended jobs or troubleshooting. /R:n sets the retry count, and /W:n sets the wait interval in seconds. For example:

robocopy "C:Source" "D:Backup" /E /R:3 /W:10 /LOG:"C:LogsRobocopy-run.log"

This example allows three retries and waits 10 seconds between them. Choose values that fit the reliability of the source and destination; a low retry count can leave transiently unavailable files uncopied, while the defaults can make a failed operation appear to hang for a very long time. Retry settings concern availability and completion, not whether destination-only files are eligible for purge.

Rank #4
ModusTech Facet 500GB External Hard Drive Portable USB-C/USB 3.1 Plug & Play Ultra- Slim HDD Hard Drive for Backup, Gaming, PC, Mac, Laptop, PS4, Xbox, Smart TV (Black)
  • High-capacity external hard drive with up to 2TB of storage The ModusTech Facet portable external hard drive gives you dependable HDD storage in a slim 2.5-inch design. Multiple capacities available up to 2TB — back up photos, videos, music, documents, and game libraries with room to grow. A trusted external storage solution for everyday backup, media archives, and creative work.
  • USB-C and USB 3.1 connectivity with included 2-in-1 cable The Facet ships with a USB-C to USB-C cable and tethered USB-A adapter, so this external hard drive connects to modern laptops, USB-C iPhones, tablets, and older USB-A computers without buying an extra cable. USB 3.1 Gen 1 (5Gbps) interface delivers real-world transfer speeds up to 100MB/s — fast enough to back up 50GB of files in about 8 minutes.
  • Plug-and-play external hard drive for PC, Mac, and laptops Preformatted in exFAT and ready to use the moment you plug it in. The Facet works out of the box with Windows PCs, macOS Macs, MacBooks, Chromebooks, and laptops — no drivers, no software, no setup required. A true plug-and-play external hard drive built for everyday use across every major operating system.
  • External hard drive for PS4, Xbox One, and Smart TV gaming The Facet is compatible with PlayStation 4, Xbox One, and Smart TVs with USB support. PS4 and Xbox One games run directly from the drive — plug it in, format through the console, and add to your storage. Also works with Smart TVs that support USB recording or external media playback.
  • Slim, shock-resistant portable external hard drive — 160g At 2.5 inches and just 160g, this portable external hard drive is bus-powered through a single USB-C cable — no separate power adapter, no extra cables. Slim enough for a laptop bag, jacket pocket, or camera bag, with a shockresistant casing and faceted diamond-texture top panel that resists fingerprints and everyday wear. Backed by a 1-year limited warranty from ModusTech, a consumer electronics brand specializing in external storage.

Important path, permission, and security details

Verify direction before execution

The source and destination are positional arguments. Accidentally reversing them can make the wrong tree authoritative and, with /MIR, expose the intended source to deletion. Read the command left to right and compare both paths with the windows you inspected.

Make sure the log location is usable

The account running Robocopy needs permission to read the source, write the destination, and create or append the log. Store the log somewhere that will remain available after the run, and do not place it inside a directory that the mirror is expected to delete or replace. If the log directory does not exist or is not writable, you may lose the record needed to assess the run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand the security-setting distinction

Microsoft notes a difference involving a destination directory’s security settings: when /E and /PURGE are used with a destination directory, those settings are not overwritten; /MIR with /E and a destination directory overwrites them. If permissions on the destination are managed separately, account for this behavior before choosing a mirror command. Treat security settings as part of the change review, not just file content.

Be cautious at a volume root

Microsoft documents a historical edge case in which /MIR or /PURGE at a volume root affected System Volume Information. Current behavior skips that named top-level item. This does not remove the need to verify paths: mirroring a volume root has a much wider scope than mirroring a specific project or backup directory.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to do when destination files must never be deleted

If the destination is an archive, a staging area shared by several users, or a folder where files are added independently, do not use /MIR merely because you want recursive copying. Start with:

robocopy "C:Source" "D:Archive" /E /L /LOG:"C:LogsRobocopy-preview.log"

Review the preview, then remove /L for the approved run. Add /XX when you want Robocopy to explicitly exclude destination-only extras from deletion:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
robocopy "C:Source" "D:Archive" /E /XX /L /LOG:"C:LogsRobocopy-preview.log"

The extra switch documents your intention, but it does not create version history, undo a prior deletion, or protect against a mistaken source path. A separate destination, such as another physical drive, can be part of a backup design, but no destination is safe from a command aimed at the wrong path. If you need recoverable historical versions, use a backup system that retains versions rather than relying on a mirror.

Best Value
Sale
WD 5TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBPKJ0050BBK-WESN
  • Slim durable design to help take your important files with you
  • Back up smarter with included device management software[2] with defense against ransomware
  • Help secure your important files with password protection and hardware encryption
  • 3-year limited warranty

Troubleshooting a surprising preview or result

  • Unexpected deletions are listed: Stop before removing /L. Recheck the source path, inspect every listed extra, and switch from /MIR to /E (with /XX if appropriate) when those extras must remain.
  • Nothing appears to copy: Confirm that the source contains the expected files, that the destination is the intended one, and that the preview is not showing an already synchronized tree. Check the log and return code.
  • Files are missing from the operation: Inspect /XD, /XF, and /XJ arguments. A pattern or path can exclude more content than intended.
  • The command takes an extremely long time: Review /R and /W. The documented defaults can cause repeated retries with long waits when a file or destination is unavailable.
  • The return code is 8 or higher: Open the log, identify failed paths, and correct permissions, connectivity, locks, or storage errors before treating the mirror as complete.
  • Destination permissions changed: Revisit the distinction between /E /PURGE and /MIR described in Microsoft’s command reference, and test security requirements with a preview and a controlled directory.
  • A junction causes unexpected traversal: Add /XJ if linked directory locations should not be followed, then preview again to confirm the reduced scope.

A final preflight checklist

  • The source path is the authoritative tree.
  • The destination path is correct and writable.
  • Any destination-only files that must remain have been identified.
  • The command has been run with /L.
  • The preview and log show no unintended deletions.
  • Exclusions are deliberate and correctly spelled.
  • Retry and wait values are suitable for the job.
  • The real run retains /LOG: or /LOG+:.
  • The return code and log will be reviewed after completion.

The safe way to mirror with Robocopy is not to find a special “undeletable” form of /MIR; it is to verify the direction, preview the exact changes, choose /E when destination extras must survive, and treat the log and return code as part of the operation.

Frequently Asked Questions

How do I mirror folders with Robocopy without deleting files?

Do not use /MIR when destination-only files must survive. Use /E for recursive copying, add /XX when you want extras explicitly excluded from deletion, preview with /L, and review the log before the real run.

Does Robocopy /MIR delete files?

Yes. Microsoft defines /MIR as /E plus /PURGE. Destination files and directories absent from the source can be deleted during a real run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How can I preview a Robocopy command before it runs?

Add /L. For example: robocopy "C:Source" "D:Backup" /MIR /L /LOG:"C:LogsRobocopy-preview.log". List-only mode does not copy, delete, or timestamp files.

Is /E safer than /MIR for an archive?

For retaining destination-only content, yes. /E copies subdirectories, including empty ones, without itself invoking purge. Preview it and use /XX when appropriate.

What does /XX do?

It excludes destination-only extra files and directories from deletion. The result is not an exact mirror because content absent from the source can remain at the destination.

Should I remove /L after checking the preview?

Only after confirming the source, destination, exclusions, and every planned deletion. Keep the log switch for the real run and review the resulting return code.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What do Robocopy return codes 8 and above mean?

They indicate that at least one failure occurred. Read the log, identify the affected paths, and correct permission, connectivity, locking, or storage problems before treating the operation as complete.

Can Robocopy mirroring protect older file versions?

No. A mirror reflects the current source tree and can remove destination copies of files deleted from the source. Use a versioned backup design if historical recovery is required.

The Bottom Line

Never treat /MIR as a deletion-free backup switch. Verify the source and destination, preview the exact command with /L, inspect the log for destination-only items, and use /E (optionally /XX) when those items must remain. Keep a log, review the return code, and remember that a mirror preserves the current tree—not older versions.

Quick Recap

Bestseller No. 1
WD 2TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBYVG0020BBK-WESN
WD 2TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBYVG0020BBK-WESN
Slim durable design to help take your important files with you; Help secure your important files with password protection and hardware encryption
$132.10
Bestseller No. 3
WD 4TB My Passport, Portable External Hard Drive, Black, Backup Software with Defense Against ransomware, and Password Protection, USB 3.1/USB 3.0 Compatible - WDBPKJ0040BBK-WESN
WD 4TB My Passport, Portable External Hard Drive, Black, Backup Software with Defense Against ransomware, and Password Protection, USB 3.1/USB 3.0 Compatible - WDBPKJ0040BBK-WESN
Slim durable design to help take your important files with you; Help secure your important files with password protection and hardware encryption
$180.00
SaleBestseller No. 5
WD 5TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBPKJ0050BBK-WESN
WD 5TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBPKJ0050BBK-WESN
Slim durable design to help take your important files with you; Help secure your important files with password protection and hardware encryption
$219.95

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.