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.
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.
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.
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.
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.