Apr 09, 2021 • Filed to: Take Data Backup • Proven solutions
Want to sync files between devices? Then here is new tool to try. Robocopy sync is the new way to go for file sync function. Use Robocopy to sync folders. This article is your guide to know how to. Robocopy is a very powerful tool and specifically, the Robocopy /mir command allows for robust and useful file and folder mirroring across folders and network shares. With the addition of a few useful commands, Robocopy becomes even more powerful and reliable copying files over a network using the Robocopy /mir command. Robocopy script to synchronize folders Posted: July 7, 2018 in Scripts. Requirements: If a file is deleted in source, remove it from destination as well.
I'm using robocopy to copy files to a samba share. The drive contains around 800 GB of data with over a million files that are 20-80K each. The issue I'm having is that robocopy copies all files each time (which takes around 12 hours). I'd like it to only copy new or changed files each time. Below is the command line I'm using:
robocopy d: sambashare /e /z /r:0 /w:0 /copy:DAT /xd $RECYCLE.BIN /xd 'System Volume Information'
I've used these options when copying to Windows shares and it's worked as I want but for whatever reason when copying to a samba share it copies all files. Any ideas on how to get robocopy to only copy new/changed files to a samba share? Also, anyone has a better solution than robocopy?
Synchronization or syncing files is an important task that should not be taken for granted. It is a way in which you can keep the updated version of your data and use it as restore points. In case of any disaster i.e. technical (system crash) or physical, you may lose your data. Using the synced copy of data, you can rehabilitate your device to the last working condition. Though there are several built-in tools and mechanisms for carrying out the sync function, yet there is a new tool in the market. Robocopy is there to sync your files. This article is all about the introduction of Robocopy /xo as a tool, Robocopy sync capabilities, and how to use Robocopy to sync folders.
As a tool, Robocopy (robust file copy) is a special command-based directory that works on commands to deal with syncing and copying functionalities for the windows operating system. It is a top-notch feature presented by windows with NT4.0. Robocopy became a standard utility of windows with the arrival of Vista. The command line used in the utility is different from the regular ones as it excels in mirroring and copying folders and directories of any size. Along with copying the folders, the Robocopy cmd mirror the essentials like timestamps, properties, and NTFS ACLS. For the network-based folders, Robocopy /xo comes up with a feature of resume copy. With this feature, it can tolerate the faulty network and resume the sync function from the point it left, as the name implies 'resume copy'. It also has the capacity of skipping the infinite loops that causes sync failures. It can copy between the ranges of 259-32,000 characters without any error. As mentioned above, this tool works on command lines, so here are some of the commands that are employed to copy the files/folders.
- /S - Copies subdirectories, excluding empty ones
- /LEV:n - Copies the higher 'n' levels from the source
- /Z - Restartable mode
- /B - Backup mode
- /ZB - Restartable mode; otherwise backup mode
- /SEC - Copies with security
- /COPY ALL - Includes all file info while copying, including security info
This article would be discussing every detail linked to this Robocopy /xo and gives a thorough explanation regarding how to use Robocopy to sync folders. Here are the topics that would be discussed in detail.
Part 1: Advantages of Copying Only Changed or New Files with Robocopy
As mentioned above, Robocopy /xo is used to copy the files and folders on the network along with the complete directories, you can also employ the tool copying only new files i.e. Robocopy only new files. Using Robocopy for this purpose is quite common. Why? Let's have a look!
- Time-saving: Copying the changes does not take much time. So despite copying all files and folders time and again would take time, use the tool to copy or mirror the changes made on files and folders.
- Disk space-saving: Creating backup for files and folders again and again not only introduce errors rather it requires a huge space for storage. Copying the same files would occupy all the space on disk and leaves no room for the new one. So to avoid the overcrowding, copying the new changes with Robocopy is a smart move.
These two points are valid to save time and to avoid space linked issues. Hence, Robocopy /xo can be used for syncing/copying/mirroring the new files only i.e. Robocopy copy only new files.
Part 2: How to Copy Changes Only with Robocopy Command?
As mentioned above, Robocopy copy only new files technique is fascination g for all. It helps to sync files and folders quite easily without consuming time and disk space. So here are the steps to elaborate on how to copy changes only with the Robocopy command.
Step 1: In the main menu of windows, click Start, and in the search box, type CMD to run the command prompt.
Step 2: In the drop-down, select the option of command prompt and again in the drop-down click on run as administrator.
Step 3: As soon as the command prompt launches, type the desired Robocopy command lines to perform the targeted function. Here is the command:
robocopy / maxage:
Here '/maxage:' denotes the farthest modification time. The file with a huge time frame would not be copied i.e. as mentioned above, it can only copy the newly made changes to save time and space.
Here are some of the commonly employed command parameters:
- /XC :- eXclude Changed files.
- /XN :-eXclude Newer files.
- /XO :-eXclude Older files.
- /IS :- Include the Same files.
- /E:-means copy all subdirectories including empty folders
Enter the desired command line or parameter in the command prompt and leave the rest to this amazing tool. It will copy/sync/mirror smartly.
Part 3: How to Copy Only New or Modified Files with AOMEI Backupper?
Sometimes, it is quite difficult for the users, mostly for the newbies to use the command lines. They can make mistakes and end up with no results. So here is an alternative for the, using a third party application software that can help at this time. AOMEI more backup professional is a top-notch backup software that carries outstanding data migration tools. It is compatible for your Windows 10/8/7, XP, and Vista. It helps to create systems and disk images that occupy less space. Here is how you can use the software to sync or copy files and folders.
Step 1: Download the software and then run an install as administrator.
Step 2: Once installed successfully, launch the software on your device, and in the main interface select the option of backup followed by selecting file backup.
Step 3: In the file backup window, the next step is to click on the add folder to add the source drive/folder targeted for backup. Click ok to proceed.
Step 4: From the drop-down, select the destination drive (be it Cloud drive, shared folder, or NAS).
Step 5: In case you want to schedule the backup function, configure the schedule settings. Check the box of differential backup and click ok to continue.
Step 6: Once all steps are completed, click start backup to complete the action.
Your backup would be automatically saved on the destination location/drive. Scheduling your backup can be done on a daily, weekly, or monthly basis. Moreover, you would get an email notification regarding the completion or failure of the process.
Hence, as mentioned earlier, synchronization or syncing the files and folders saved on multiple locations is an important task. You have to carry out a regular sync function to keep your data updated on all locations. In this regard, Windows present you with a built-in sync tool i.e. Robocopy /xo. It is used by the users to copy/sync and mirror the files and folders efficiently. The top-notch tool helps to perform the sync function smartly, as it only syncs/copy the files and folders only for new changes. This can help to save time and disk space. The tool follows the command lined based technique for carrying out functionality. Enter the particular command line and you are done with the task in no time. But using command lines is not easy. So for the newbies, here is this third party help alert. You can use AOMEI backupper professional for creating file backups in a few steps.
Data Backup Services
- Computer Backup
- Hard Drive Backup
- Mac Backup
- Cloud Backup
I am sure you have needed to copy files from one server to another. Sometimes it is sufficient to use Windows Explorer across a UNC path and do a simple copy and paste. With that simplicity comes the lack of control and advanced features. Two great free options exist that can be set to run as a scheduled task in a simple batch file, XCOPY and Robocopy.
Learn how our valet services can save you a fortune in support costs
If you are familiar with XCopy, you know that it has a variety of parameters that can be configured to meet many of your business requirements. If you need more advanced features then Robocopy will most likely meet your needs. You can think of Robocopy as XCOPY on steroids, providing features that tolerate network interruptions, skip identical files, and so forth. The latest version also includes multithread copying.
Robocopy and XCopy are both good solutions to keep a backup copy of your files in a remote location. When your requirements include the need to synchronize the same files across multiple servers, you can setup multiple Robocopy jobs that keep files in sync in multiple directions. That can quickly turn into an administrative nightmare.
Fortunately there is another technology that makes this an easy task to accomplish and administer known as Distributed File System (DFS). This technology started to come to maturity with the release of Windows Server 2003 R2 and continues to improve with each release of Windows Server, including Windows Server 2008 R2 and Windows Server 2012 (also known as Windows Server 8). While there are a multitude of guides on the Internet about DFS including all of the different features and configuration options, I want to hone in on a simple feature that many of us come across regularly; the need to keep a set of files and folders synchronized across multiple servers.
Before we start you should note that in order to properly use DFS, the servers need to be part of an Active Directory Domain. If they are not then you either need to add them to a domain or fall back to using Robocopy or XCopy. In this demo we will be synchronizing a single folder across two servers.
The first step is to install the DFS Role on each of the servers that you want to synchronize files between. In Server Manager, highlight Roles in the left tree view and select Add Roles under Roles Summary.
This brings up the Add Roles Wizard. On the Select Server Roles page, check the box beside File Services and click Next.
On the Select Role Services screen, check the box for DFS Replication. For this scenario we don’t need DFS Namespaces. Click Next.
Now you will finish the steps of the wizard to install DFS Replication. Once you have DFS Replication installed on each of the servers, we can move forward with configuring DFS Replication.On the server, click Start -> Administrative Tools -> DFS Management. This opens up the DFS Management console. Right click Replication and choose New Replication Group.
You are now presented with the New Replication Group Wizard. Stay with the default selection of Multipurpose replication group and click next.
At the next screen give the replication group a meaningful name. You will notice that your default Active Directory domain is set. If not, click Browse… to select it.
Next select two or more servers that you want to synchronize files across. Click Add and look up the servers in Active Directory. Once you have the servers selected click Next.
Robocopy Sync Network Folder
For the topology, we will select Full mesh. That allows the files to stay in sync between all of the servers regardless of where the file is updated. You will note that to use Hub and spoke, you need at least three servers and it increases the complexity of your DFS environment. I have only had a couple of scenarios where I have needed to use Hub and spoke.
At this screen you can limit the bandwidth and even configure DFS to run on a schedule. Since we are on an intranet network we’re going to use full bandwidth and we want to keep the files in sync all the time so the default options work well for us. Click Next after you have configured this to your liking.
Next we need to select the Primary member. Full mesh topology treats all servers as equals and keeps all the files synchronized nearly instantaneously after the first synchronization is complete and the DFS database is built. For the first synchronization, though, DFS needs to know which server to set as the primary member if there are file conflicts. In that case, it treats the files on the Primary member as the master files just this one time. After the initial synchronization there is no longer a Primary member. Click Next after selecting your Primary member.
Robocopy Sync Folder
It is time for us to select the folders that we want to replicate. Click the Add… button to bring up another window. Click the Browse… button to pick a local folder on this server to replicate. You can use the automatically generated name of the folder or pick a custom name if needed. You will note that you can also set custom permissions. From my experience the default existing permissions will work in most situations. Click the Next button when you’ve picked the local folder.
You are now presented with a screen for the other server that you selected in the replication group. You will note that the local path is not set and it is disabled. Make sure it is highlighted and click the Edit… button. Here you will select enabled and choose the local folder on the remote server. While you can set a target path on the remote server that is different than the path on the local server, I recommend that you keep the paths the same on both servers to simplify management. Click OK and then Next.
Robocopy Sync Folders
You are presented with the final screen that gives you one last chance to review what you have selected. Once you have reviewed the settings, click the Create button. You will be prompted with a reminder that it will take some time for the initial replication to occur. From my experience it usually takes from 15 – 30 minutes for initial replication to begin. After that, it can take some time for initial replication to complete based on the number and size of the files.
Following the steps above, you can now easily keep sets of folders synchronized between multiple servers.