How to synchronize folders between two Windows Server 2012
Is there any best practice of how to synchronize folders between two Windows Server 2012 server installed?
Solution 1:
Windows Server has a distributed and replicated file system called DFSR. This is not a new technology to Windows Server, but the Server 2008 and later versions are substantially improved over the Server 2003 version.
There are two parts to this:
- Distribution
- Replication
Distribution
With DFS, you create a namespace. That namespace is generally \\domain.tld\namespace
. For example, \\example.local\files
. This namespace then has member servers. If your Active Directory Sites and Services is set up appropriately with the corret subnets applied to the correct sites, then each site will connect to its closest server.
This in its own isn't particularly useful though. Yes, it means that every computer on the network can use the same network path and expect a fast speed, but just connecting the namespace to different servers isn't particularly useful for your situation, as you also need the same data on each server.
Replication
DFSR replicates data between shares on multiple servers. There are a variety of different topologies you can choose from, but "Full Mesh" is a popular one. This means that every DFS node can "see" every other DFS node, and replicates all the changes from each individual DFS store. This means that a file written to one server will appear on all the other DFS members within a fairly short period of time.
With a Hub and Spoke topology, where not all the DFS members can see eachother, but they can all see one central server, then all changes are replicated to/from the central server. This effectively means that all replications take 2 steps to get to all the other nodes (Original > Central, then Central > Other Nodes).
With 2 servers, "Full Mesh" is the only viable replication option.
Using them together
Now, you actually don't need to use DFS and R together. You can replicate two folders without presenting them in a namespace, and as previously mentioned, you can present a non-replicated namespace. Generally though you would use both together.
Another thing to note is that even though it's called "Distributed File System" it's not a block-level file system like you might associate with say, GlusterFS. All changes are made at file-system level and then the deltas are replicated. This can lead to multiple changes made on different servers conflicting with eachother, as there's no locking mechanism between DFS nodes, or if there is application-level locking, the locks may take time to replicate between all the nodes to indicate that the file is locked.