Syncing Two Folders with Robocopy: Keeping Five Copies of Target Folder

Abstract: Use Robocopy with the /MIR switch in a loop to maintain five identical folder backups that automatically reflect source deletions.

Created: 2026-09-23 by
To keep five copies of a target folder synchronized with a source directory, you must use the Robocopy command with the /MIR switch. This flag mirrors the source tree, including deletions, ensuring the destination matches the source exactly. You should run this command in a loop or schedule it to maintain the required number of backups without manual intervention.

Understanding the Mirror Switch

The core challenge in maintaining multiple identical folders is handling file deletions. If you simply copy new files, old files that were removed from the source will remain in your backup folders, causing divergence. The /MIR (Mirror) option solves this by performing a two-way sync: it copies new and updated files from the source to the destination, and crucially, it deletes files in the destination that no longer exist in the source. When you use /MIR, Robocopy replicates the entire directory structure. This includes empty directories if they exist in the source. It is important to note that /MIR is equivalent to using both /E (copy subdirectories, including empty ones) and /PURGE (delete files and directories in the destination that no longer exist in the source). Using /XO (exclude older files) alongside /MIR is incorrect because /XO prevents the deletion of older files, which directly contradicts the purpose of mirroring where the destination must reflect the current state of the source.

Configuring Multiple Target Copies

Robocopy only accepts one destination path per command execution. Therefore, to maintain five separate copies, you cannot list all five destinations in a single command line. Instead, you must execute the Robocopy command five times, once for each target folder. You can automate this process using a batch script or a scheduled task. Here is the basic structure for a single synchronization step:
robocopy "C:\SourceFolder" "D:\Backup1" /MIR /R:3 /W:5
In this example, replace "C:\SourceFolder" with your actual source path and "D:\Backup1" with the first backup location. The /R:3 parameter sets the number of retries on failed copies to three, and /W:5 sets the wait time between retries to five seconds. Adjust these values based on your network speed and storage reliability. To create five copies, you would repeat this command four more times, changing the destination path for each iteration:
  • robocopy "C:\SourceFolder" "D:\Backup1" /MIR /R:3 /W:5
  • robocopy "C:\SourceFolder" "D:\Backup2" /MIR /R:3 /W:5
  • robocopy "C:\SourceFolder" "D:\Backup3" /MIR /R:3 /W:5
  • robocopy "C:\SourceFolder" "D:\Backup4" /MIR /R:3 /W:5
  • robocopy "C:\SourceFolder" "D:\Backup5" /MIR /R:3 /W:5
This approach ensures that each backup folder is an independent mirror of the source. If a file is deleted from the source, it is removed from all five backup locations. This method avoids the complexity of managing symbolic links or complex directory structures that might lead to infinite duplication loops. For more details on preventing such issues, see Avoiding Infinite Subfolder Duplication with Robocopy on Windows.

Optimizing Performance and Reliability

Running five full mirror operations can be resource-intensive. To optimize performance, consider adding logging options. The /LOG+: switch appends log information to a specified file, which helps in troubleshooting future synchronization issues. Without logging, determining why a specific file was not copied or deleted can be difficult.
robocopy "C:\SourceFolder" "D:\Backup1" /MIR /R:3 /W:5 /LOG+:C:\Logs\sync_backup1.log
Additionally, you may want to exclude certain temporary files or system folders that do not need to be backed up. While /MIR handles the main synchronization, adding /XF (exclude files) and /XD (exclude directories) can reduce the load on your storage system. However, be cautious when excluding files during a mirror operation, as this can lead to inconsistencies if the exclusions are not applied consistently across all five targets. It is also advisable to check the exit codes returned by Robocopy. A standard success code is 0, but codes 1-7 indicate various states of success with warnings (e.g., some files were skipped). Monitoring these codes allows you to detect failures early. For deeper insights into error handling, refer to Understanding Robocopy's /PURGE and /MOVE Options.

Scheduling the Synchronization

Manual execution is prone to human error. Use Windows Task Scheduler to run your batch script at regular intervals. Create a new task that triggers either on a schedule (e.g., every hour) or on system startup. Ensure the task runs under an account with sufficient permissions to read the source and write to all five backup destinations. When configuring the task, specify the action as "Start a program" and point it to your batch file. In the "Add arguments" field, you can pass any additional parameters if your script requires them. Set the task to run whether the user is logged on or not to ensure background synchronization. Remember that network latency can affect the speed of synchronization, especially if your backup drives are located on a different server. Using the /MT:n switch (where n is the number of threads) can significantly speed up large file transfers. For example, /MT:8 uses eight threads to copy files in parallel. This feature is particularly useful when dealing with thousands of small files, as it reduces the overhead of opening and closing individual file connections.

Verifying Synchronization Integrity

After setting up your five copies, verify that they are truly synchronized. You can do this by creating a test file in the source folder and checking if it appears in all five backup locations within the expected timeframe. Conversely, delete a file from the source and confirm its removal from all backups. If discrepancies arise, check the log files generated by Robocopy. Look for errors related to access permissions, disk space, or file locking. Ensure that no other processes are actively writing to the backup folders during the synchronization window, as this can cause transient errors. Regularly reviewing these logs helps maintain the integrity of your backup strategy over time.

Frequently Asked Questions

Can I use /MIR with a network share?

Yes, you can use /MIR with network shares, but ensure you have proper read/write permissions on both the source and destination paths. Network latency may slow down the synchronization process, so consider increasing the retry count and wait time parameters.

What happens if a backup drive is offline?

If a destination drive is offline or disconnected, Robocopy will skip that specific copy operation and return an error code indicating failure. The other four backups will still be updated successfully. Check the logs to identify which backup failed and reconnect the drive before the next scheduled run.

Is there a way to sync only changed files instead of mirroring everything?

Yes, you can use the /COPYALL switch combined with /TEE and /NP for a simpler output, but for true synchronization without deleting old files, avoid /MIR. Instead, use /E to copy subdirectories and let Robocopy handle updates naturally. However, this means deleted files in the source will remain in the backup.

How do I prevent accidental data loss during mirroring?

Always test the /MIR command on a small subset of data first. Consider keeping one backup folder without the /MIR switch (using only /E) as a safety net to preserve historical versions of deleted files. Review the documentation on Understanding Robocopy's /PURGE and /MOVE Options to understand the risks involved.

Can I use Robocopy to sync more than five copies?

Absolutely. The logic remains the same: execute the Robocopy command once for each target destination. Whether you need ten copies or twenty, simply add more lines to your batch script or scheduled task sequence, adjusting the destination paths accordingly.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More