User Case: How Do I Sync Two Folders with Robocopy?
"Hi, we have two shared folders. One is primary which is shared with the user and almost about to fill and the other is not shared yet but I want to sync all the data from primary to new one with Robocopy command line.
The problem is how do I sync two folders with Robocopy? I don't want to sync current files already in the new folder, only changes in the primary folder to new folder. Thanks."
Sometimes, you may need to sync two folders located in different computers or other locations, such as, internal or external drives, to make the two folders keep the same content. Here we will show you different ways to perform Windows sync two folders with command line tool.
Robocopy Command Line Syntax and Options
Robocopy is a robust file copy command for Windows PCs and it allows you to copy files, directories, and even drives from one location to another. It provides you with different parameters to sync two folders in Windows 11/10/8/7.
👉 Robocopy command line syntax: You can specify the path to source and destination directory, files or folders you want to sync and other options.
robocopy [Source] [Destination] [(File)( ...)] [(Options)]
|Source||It specifies path to source directory, type as, drive:\path or \\server\share\path.|
|Destination||It specifies path to destination directory, type as, drive:\path or \\server\share\path.|
|File||It specifies files you want to copy, type as, names/wildcards: default is "*.*".|
|Options||It specifies copy, file, retrt, logging, and job options to use with robocopy command.|
👉 Common used options in Robocopy:
/s: Copies subdirectories. Note that this option excludes empty directories.
/e: Copies subdirectories. Note that this option includes empty directories.
/lev: Copies only the top N levels of the source directory tree.
/z: Copies files in restartable mode.
/b: Copies files in Backup mode.
/zb: Uses restartable mode. If access is denied, this option uses Backup mode.
/efsraw: Copies all encrypted files in EFS RAW mode.
/copyall: Copies all file information, including D (Data), A (Attributes), T (Time stamps), S (Security: NTFS access control list (ACL)), O (Owner information), U (Auditing information)
👉 To know more parameters you could use, please input robocopy /? to get more details.
How to Perform Robocopy One-Way Sync Two Folders
In general, Robocopy is a one way file sync solution, and you can sync files easily from one location to another as long as you use the right options. And I will introduce you to the most common cases below. Note that you need to run cmd as administrator in all the following situations.
Situation 1: Robocopy Sync Two Shared Folders
The first case is to sync two folders on different computer through shared folder. For example, to sync tmp folder(and its subfolders) located in \\192.168.0.250\PublicShare\ to \\192.168.0.58\WorkD, please input the following command line:
robocopy \\192.168.0.250\PublicShare\temp \\192.168.0.58\WorkD /e /copy:DAT /mt /z
/copy:DAT: means you will copy the source folder to destination folder with D (Data), A (Attributes), T (Time stamps), and you could modify these copied files. If you don’t want to modify these folders and files, you could replace /copy:DAT to /copyall or /copy:DATSOU.
/mt: Creates multi-threaded copies with 8 threads.
Situation 2: Robocopy Incremental Sync
Except for simply sync two shared folers, you still can create incremental sync task with Robocopy command line. You will use the /xo or /xc option, which has the ability to let Robocopy sync changes only to the destination folder.
For example, to sync changed part from source \\192.168.0.250\PublicShare\temp to \\192.168.0.58\WorkD in restart mode and creates multi-threaded copies with 8 threads, input the following command line:
robocopy \\192.168.0.250\PublicShare\temp \\192.168.0.58\WorkD /e /copy:DAT /mt /z /xc /xn /xo
/xo: Excludes older files (excludes existing files older than the copy in the source directory).
/xc: Excludes changed files (excludes existing files with the same timestamp, but different file sizes).
/xn: Excludes newer files (excludes existing files newer than the copy in the source directory).
/mt: Enable multithreaded copying and the default threads is 8. If you don't want to use the default, you can specify it yourself.
With /xc, /xn, /xo specified, Robocopy will exclude files existing in the destination directory.
Situation 3: Robocopy Real Time Sync Two Folders
Besides, Robocopy still offers you /mot: to monitor changes in M minutes (only accept minutes as argument). Note the changes less than one minutes will not be included.
For example, monitor every one minutes based on the above command, type the following command:
robocopy \\192.168.0.250\PublicShare\temp \\192.168.0.58\WorkD /e /copy:DAT /mt /z /xc /xn /xo /mot:1
/mot:: Monitors the changes in source every N minutes and sync it to destination.
Other Robocopy Sync Situations
Except for the above cases, you still can use batch files and Windows Task Scheduler to continuously copy all file changes.
Besides, you could specify the mirror sync task with the /purge parameter, it will delete destination files and directories that no longer exist in the source.
For two-way sync, you need to create a batch file with Notepad. For detailed steps, please refer to Robocopy two-way sync.
Windows Sync Two Folders Command Line Limitation
Robocopy is good assistant to helps you perform one way, but there are some restrictions using Robocopy sync two folders:
Robocopy parameters are quite complicated for computer novices to understand.
Robocopy does not copy open files.
Robocopy does not mirror files properly in system older than Windows Vista.
- Robocopy will disable reporting of the progress percentage for files that are ignored if you use /mt option.
You will lose important files and folders once specified the wrong parameters.
Easier Way to Sync Two Folders in Windows
Except for the Robocopy command line, you still can try GUI-based file synchronization software - AOMEI Backupper Professional. It supports Windows XP, Vista, 7, 8, 8.1,10 and 11(32-bit and 64-bit) and helps you sync two folders easily with the following options.
- Basic Sync: It will sync files from one location to another and supports daily, weekly, monthly, event trigger and USB plug in schedule sync settings.
- Real-Time Sync: It will monitor and sync changes imediately once it's detected, thus maximizing the retention of changes.
- Mirror Sync: It is a one-way file sync method and more concerned about files in the destination, any change will be undo, and you cannot add new files to it, or delete files already in it.
- Two-Way Sync: Unlike previous 3 methods, it will sync files between source and destination directory. All the schedule sync settings are supported.
Besides, it still allows you to sync two folders to multiple destinations, such as local disk, external hard drive (HDD or SSD), CD/DVD, USB flash drive, network share or NAS, even to cloud drives like Google Drive, Dropbox, OneDrive, Box, etc.
To get started, please download AOMEI Backupper Professional and install it on a Windows PC. For server users, try AOMEI Backupper Server!
Step 1. launch AOMEI Backupper Professional on your Windows 10 computer, select Sync tab and then a method to sync two folders, here take Real-Time Sync as an example.
Step 2. Press + Add Folder button and then Share/NAS.
Step 3. Click Add Share or NAS Devices and then input the display name and network path to add the network share, and choose the folders you want to sync. You still need to type username and password if you receive error while adding network path.
Step 4. Click the triangle icon and tap Add Share or NAS Devices, type network path in the pop-up window and select another folder as destination.
Step 5. Hit Start Sync >> to sync two folders in real time in Windows. Optionally, you can click Options to comment the real time folder sync task, email or SMS notification, and verify the integrity of the files in the destination location during synchronization, etc.
After the first full folder sync, then any changes made on the source folder will be synced to the destination immediately. It's the safest way to protect files, and meanwhile, it will take up the most disk space compared to other sync methods.
Of course, if you mind the disk space issue, you can also use other sync methods (eg: Mirror Sync) to sync files with daily, weekly, or monthly frequency, or based on event triggers, USB plug in. This can alleviate the disk space problem to some extent.
To completely resolve this issue, you could consider using the Backup feature to duplicate files. It not only schedules backup files but also deletes old backup images automatically to free up disk space. You have 3 options in following:
- By quantity: The default number of backup set is 1 and the old backups in it will be deleted after exceeding.
- By time: The default set time is 7 days, you can set more or use week(s) or month(s) as basis.
- By daily/weekly/monthly: This method is the safest, which keep all the backups within several days, and then only full backups in weeks, finally only one full every month .
Besides, you still can choose to backup folders to AOMEI Cloud, a cloud drive with 1TB of free storage, and you have 15 days of free access to it after registration. And it enables you to run this task automatically, such as, daily, weekly, or monthly.
Compared with Windows sync two folders via command line tool - Robocopy, the best file sync software - AOMEI Backupper Professional provides you flexible ways to sync two folders in Windows 11, 10, 8, and 7. You can choose different sync methods and schedule settings based on your needs.
In addition, it still a professional backup software. If you don't want the files occupying much disk space, try the File Backup feature. And then, you can enable schedule backup, incremental or differential backup and automatic backup cleanup to manage backup task and disk space flexibly.