Yes, Robocopy can sync folders one way. It copies files from a source to a destination and, with the right switches, can delete files in the destination that no longer exist in the source, making the destination a mirror of the source. You run it from the Command Prompt or PowerShell, and it is built into Windows, so there is nothing extra to install.
What Robocopy Is and Why It Is Used
Robocopy (Robust File Copy) is a command-line tool that has shipped with Windows since Windows Vista and Windows Server 2008. It is designed to copy large numbers of files reliably, resume interrupted copies, and handle long paths and file names that the older copy and xcopy commands struggle with. Many system administrators use it for backups, for moving data between servers, and for keeping two folders in sync on a schedule.
Unlike a sync tool that runs in the background, Robocopy runs when you tell it to. You can run it manually, put it in a batch file, or schedule it with Task Scheduler. It does not watch for changes in real time; it compares the source and destination each time you run it and copies only what is different, which makes repeated runs fast.
How One-Way Sync Works
One-way sync means data flows only from the source to the destination. Changes made in the source are pushed to the destination; changes made in the destination are overwritten or deleted so that the destination ends up exactly like the source. The opposite direction is never applied.
Robocopy achieves this with the /MIR switch, which is short for “mirror.� The /MIR switch does two things: it copies all files and folders from the source to the destination, and it deletes files and folders in the destination that do not exist in the source. That deletion is what makes the destination a true mirror. Without /MIR, Robocopy only adds new or updated files; it never removes extra files that are already in the destination.
Basic Command and Switches
The basic syntax for a one-way sync is:
robocopy source destination /MIR
For example, to mirror the folder D:\Data to an external drive E:\Backup, you would type:
robocopy D:\Data E:\Backup /MIR
That command copies everything from D:\Data to E:\Backup and deletes anything in E:\Backup that is not in D:\Data. It also copies the folder structure, including empty folders, because /MIR implies /E (copy all subdirectories, including empty ones).
You can add other switches to change the behavior:
/COPY:DAT— copies file data, attributes, and timestamps (this is the default)./DCOPY:T— copies directory timestamps./R:n— number of retries on failed copies (default is 1,000,000)./W:n— wait time between retries in seconds (default is 30)./LOG:filename— writes a log file of the operation./NP— no progress percentage, which keeps the log cleaner./TEE— shows the log in the console and writes it to a file at the same time.
A common backup command that logs its output and retries a few times is:
robocopy D:\Data E:\Backup /MIR /R:3 /W:10 /LOG:C:\BackupLogs\backup.log /NP
Choosing the Right Switches
While /MIR is the key to one-way sync, you should think about which switches fit your situation. The default copy settings are fine for most files, but if you are copying to a different file system, you might need to adjust them.
- To keep security permissions: Add
/COPY:DATSOto copy the owner and auditing information along with data, attributes, and timestamps. This requires administrative rights and is not always needed. - To skip files that are already the same: Robocopy already does this by default. It compares the file size and timestamp, so it does not recopy unchanged files.
- To handle files in use: If a file is locked by another program, Robocopy will retry and then skip it. You can use
/B(backup mode) to copy files even if you do not have explicit read permissions, but this also requires admin rights. - To avoid deleting files: If you want to copy only new and changed files, use
/Einstead of/MIR. That will not delete anything in the destination.
Remember that /MIR is destructive. It deletes files in the destination that are not in the source. If you accidentally point the source and destination the wrong way, you could lose data. Always double-check the paths before running a mirror.
Common Problems and How to Avoid Them
One of the most common mistakes is using /MIR when you only want to copy new files. If the destination already has files you want to keep, /MIR will delete them. For example, if you are copying your Documents folder to a network drive that also contains other files, /MIR would delete those other files. Use /E instead in that case.
Another issue is running Robocopy from a scheduled task and getting no output or errors. If the task runs under a different user account, it may not have permission to access the source or destination. Make sure the account has read access to the source and write access to the destination.
Long paths can also cause problems. Robocopy handles long paths better than many other tools, but if you get an error about a path being too long, you can enable long path support in Windows or use the \?\) prefix in the path, though that is rarely needed on modern systems.
Finally, be careful with the retry defaults. The default of 1,000,000 retries with a 30-second wait means that if a file is locked, Robocopy will keep trying for a very long time. Set /R:3 and /W:5 for a more reasonable behavior, especially in scripts.
Comparing Robocopy to Other Sync Tools
Robocopy is not the only way to sync folders. Free tools like FreeFileSync, SyncToy, and rsync (on Linux) can do similar things. Robocopy has some advantages: it is already installed, it is scriptable, and it is very fast because it is a native Windows tool. It also gives you fine control over what to copy and how to handle failures.
On the other hand, tools like FreeFileSync offer a graphical interface, which is easier for beginners. They also have a “mirror� mode that works the same way as /MIR, but you can see what will be deleted before you run it. Robocopy does not show a preview; it just runs.
If you need two-way sync (changes in either folder propagate to the other), Robocopy is not the right tool. It only does one-way sync. For two-way sync, you would need a tool like SyncToy or a cloud sync service.
Safety and Best Practices
Because /MIR deletes files, you should always test a new command on a pair of dummy folders first. Create two folders, put a few files in each, run the command, and verify that the destination matches the source exactly. This will help you catch mistakes without losing real data.
It is also wise to keep a backup of the destination before the first mirror run, especially if the destination already contains files. You can copy the destination to a safe location, or rename it, before running Robocopy.
When scheduling Robocopy, use a log file so you can review what happened. A simple /LOG:backup.log will create a log in the current directory. You can also use /LOG+:backup.log to append to an existing log instead of overwriting it.
Finally, note that Robocopy does not compress or encrypt data. If you need that, you should use a different tool or combine Robocopy with encryption software. Also, Robocopy does not copy files that are open and locked by another program unless you use /B (backup mode), which requires admin rights.
Frequently Asked Questions
Does Robocopy sync one way?
Yes, Robocopy is a one-way sync tool. It copies from the source to the destination and, with /MIR, deletes files in the destination that are not in the source. It does not sync changes from the destination back to the source.
What is the difference between /MIR and /E?
/E copies all subdirectories, including empty ones, but does not delete anything. /MIR does everything /E does plus it deletes files and folders in the destination that are not in the source. Use /MIR for a true mirror, and /E for a non-destructive copy.
Can I undo a Robocopy /MIR that deleted files?
No, Robocopy does not have an undo feature. Deleted files are gone unless you have a backup. This is why it is critical to test the command and keep a backup of the destination before running a mirror.
How do I schedule Robocopy to run automatically?
You can use Task Scheduler in Windows. Create a basic task, set the trigger (e.g., daily at 2:00 AM), and set the action to start a program. Enter robocopy.exe as the program, and put the source, destination, and switches in the arguments field.
Why does Robocopy skip some files?
Robocopy skips files that are already the same size and have the same timestamp. It also skips files that are locked by another program, unless you use /B (backup mode) with admin rights. If a file is skipped, it will be listed in the log with a “skipped� status.
Does Robocopy work with network drives?
Yes, you can use Robocopy with mapped network drives or UNC paths like \\server\share\folder. The account running Robocopy must have permission to access the network location, and the network must be available when the command runs.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Blockchain vs Database: When Does Distributed Trust Win?
- GTA 6 and Call of Duty on Same Console?
- MCP in Production: Security Failures Behind the Backdoor Label
- Nothing Phone 2 Waterproof? IP54 Rating Explained
- Satellite Internet Equipment & Installation Guide
- India 24 7 Kids Story Stream English Hindi Playlists3.75 count