How to Configure DFS Replication on Windows Server 2016?

This manual describes how to configure DFS data replication in the Active Directory domain on servers running Windows Server 2016.

There are two types of Distributed File System (DFS):

  1. Namespace DFS — DFS allows you to create virtual directory trees that unite shared folders across the corporate network. It is possible to configure multiple DFS namespaces. It uses simplified user access to geographically distributed files;
  2. Replication DFS — creates a replicated shared folder and tracks changes in files.

Installing DFS Namespaces and DFS Replication Roles on Windows Server 2016

Let’s install the DFS Namespaces and DFS Replication roles on the two servers running Windows Server 2016 between which the replication will be configured.

dfs replication

Use the DFS Management console (dfsmgmt.msc) to create a new DFS namespace.
You can create a domain-based namespace or stand-alone namespace.

  • Domain-based namespace — namespace integrated into the AD. Allows you to hide the DFS namespace server name from the users, simplifies the replacement of the namespace server as well as transfer the namespace to another server;
  • Stand-alone namespace — allows you to create DFS structures without using Active Directory Domain Services (AD DS) even in a workgroup. The high availability of the namespace can be achieved using a failover cluster.

windows server 2016 dfs replication

Create a new folder in the new namespace. Make sure that the new directory is accessible over the network by the UNC path dfs\namespacename\foldername (in our example it is\public\shareddocs).

setup dfs replication server 2016

Configuring DFS Replication Between 2 Servers Running Windows Server 2016

Now you can configure DFS replication. DFS Replication allows you to synchronize directories with files (replicated folders) between servers that are part of a DFS replication group. The servers within the DFS replication group are connected to each other using DFS connections.

Changes are replicated using the Remote Differential Compression Algorithm (RDC). Only the changed parts of the files are replicated. DFS replication is performed asynchronously, i.e. at a specific point in time, sources may not be consistent.

It is necessary to distinguish between simple FRS replication (File Replication Service) and DFSR (Distributed File System Replication). DFSR appeared in Windows Server 2008, and it became possible to use differential compression when performing some changes in the file, but not the entire file, is transferred over the network. In FRS replication, the entire file is copied.

Note. You can migrate Active Directory replication from FRT to DFS.

DFS replication is advantageous to use folders between remote branches over slow WAN links for replicating.

When communication between replication partners is lost, replication stops. After the network is restored, replication will continue.

A replication group is a set of servers (members) that participate in the replication of one or more folders.

DFS replication system requirements:

  • DFS Replication must be installed on all servers in the replication group;
  • Servers in the replication group must be in the same AD forest;
  • Active Directory forest schema version at least Windows Server 2003 R2, domain functional level — at least Windows Server 2008;
  • Replicated directories must be located on volumes with the NTFS file system. ReFS, FAT, and Cluster Shared Volumes are not supported;
  • Anti-virus on DFS servers must be compatible with DFS replication technology, or you must add replicated directories to the antivirus exceptions.
READ ALSO  Using Fsutil Command to Manage and Repair File System in Windows

Before configuring replication, you need to add a network shared folder on the second DFS server. Open the DFS Management console, select the desired namespace, and select Add Folder Target from the context menu.

windows dfs replication

Enter the name of the shared folder and click OK (in our example it is \\HOST2\DFS\ShareDocs).

dfs replication 2016

You will be prompted to create a new replication group. Click Yes.

configure dfs replication

Tip. If you clicked No, then in the DFS management console right-click on the Replication section and select the New Replication Group to create a new replication group.

In the DFS Replication Configuration Wizard, you need to verify the name of the replication group and the directory you want to replicate.

dfs replication windows server 2016

Check the paths to the shared folders on the servers.

server 2016 dfs replication

Select the primary member node on which the initial data is stored and from which initial replication will be performed.

setup dfs replication

As a rule, Full mesh is selected as the replication topology. In this topology, all changes on one node are immediately replicated to all the others.

dfs replication server 2016

It remains to adjust the schedule and bandwidth that can be used to replicate data. Check the settings and click Create.

A message should appear after the successful creation of a new replication group.

windows 2016 dfs replication

This completes the configuration of the DFS distributed file system and data replication in it.

Try creating a new file in the shared folder on one of the member servers. If the file size is very large, its replication can take several hours or even days, depending on the bandwidth of the communication channel between DFS servers and the DFS replication settings.

dfs windows server 2016

If 2 users simultaneously edit (or create) the same file, then DFS replicates the version of the file that was changed (created) last. An earlier version of the file is stored in DfsrPrivate\ConflictandDeleted directory on the server that resolves the DFS replication conflict. In this case, an entry about the conflict that has occurred appears in the ConflictandDeletedManifest.xml file.

Tweaking DFS Replication

After creating a DFS replication group, you can change various settings to provide better performance.

In the DFS Management console, expand the Replication section, which contains all the replication groups.

Select the replication group you created. In the right window you will see 4 tabs:

  • Membership — this is a list of network folders between which data is replicated;
  • Connections — describes the topology of relationships between DFS replication partners;
  • Replicated Folders — DFS folder settings;
  • Delegation — replication group permissions.

On the Membership tab, note the Staging Quota value—4 GB. What it is? When replicating, the DFS service uses intermediate hidden folders that store modified files which are need to be transferred to replication partners. These files are stored in a local folder DfsrPrivate\Staging on each server.

READ ALSO  Hyper-V: Nested Virtualization on Windows Server 2016

windows server dfs replication

On the Membership tab, open the properties of any folder and go to the Staging tab. As you can see, here you specify the path to the Staging folder and its maximum size (Quota). The default is 4 GB. In large infrastructures, it is desirable to increase the quota size to increase the performance of the DFS file replication service.

Microsoft recommends this quota should be not less than the total size of the 32 largest files in the replication directory. The total size of the 32 largest files in the directory can be obtained using the following PowerShell command:

Get-ChildItem C:\SharedDOCS -recurse –force | Sort-Object length -descending | select-object -first 32 | measure-object -property length -sum).sum /1gb

If the staging quota for the DFS server is insufficient, events with EventID 4208 will often be recorded in the event log. In this case, it is recommended to increase the staging quota size by 20%.

Tip. Some admins believe that a file that is larger than the quota on the Staging folder cannot be replicated via DFS. This is not true. Such file can also be replicated normally, but the replication process will take place in several stages (the file will be cut into several parts and transferred in parts), which will somewhat slow down the process.


On the Advanced tab, you can specify whether to save the files deleted by users in the ConflictandDeleted folder (it is very convenient to restore) and the quota for this folder (by default, it is also 4 GB).

dfs replication service

To switch the DFS directory on a specific server to read-only mode, click the directory and select Make read-only. As a result, users won’t be able to edit or create files in this directory.

dfs replication setup

On the Connection tab, you can temporarily suspend replication to one of the servers in the DFS replication group (Disable), or start forced replication (Replication Now).

dfsr server 2016

On the Replication Folders tab open the properties of any folder. The File filter field contains a list of file extensions that are not replicated between DFS servers. The default file extensions are .bak, and .tmp. You can add other types of file extensions that don’t need to be replicated, for example, video (*.avi, *.mpeg), audio (*.mp3, *.wav), image files (*.iso, *.wim), or other file types.

dfs namespace replication

You can control the bandwidth throttling for DFS replication between remote sites. This is useful when offices are connected by slow WAN links and you don’t want them to be completely loaded by the DFS replication traffic.

For example, the bandwidth of a WAN channel between two sites is 10 MB. You want to limit DFS to 6 megabits during business hours and to unlimited for the rest of the time.

Click on the Connections tab > right click on the replication connection and select Properties > go to the Schedule tab > Select the “Custom Connection Schedule…” > Edit Schedule > Details.

READ ALSO  Changing Expired Password via RDS in Windows Server 2012

setting up dfs replication server 2016

Here you can set a limit on the maximum channel usage by DFS replication traffic for different days of the week and daytime:

  • Monday – Friday from 8:00 AM to 5:00 PM — 6 Mb;
  • Sunday, Saturday, and Mo-Fri night — Full bandwidth.

dfsr replication

To diagnose DFS replication, you can use system event logs, as well as the current (%windir%\debug\DFSR*.log) and archive DFSR replication log (%windir%\debug\DFSR*.log.gz).

Information about DFS replication settings on the server can be obtained using the PowerShell cmdlet Get-DFSRConnection.

dfs windows 2016

Common DFS Replication Errors

Let’s consider the most common DFS replication errors and their solutions.

DFS Does Not Replicate Some Files

If you found that DFS Replication is not copying some files, check if they have the Temporary attribute set (0x120).

You can find such files and remove the 0x120 attribute using the following PowerShell script:

Get-ChildItem C:\DFS\DOCS -recurse | ForEach-Object -process {if (($_.attributes -band 0x100) -eq 0x100) {$_.attributes = ($_.attributes -band 0xFEFF)}}

DFS Replication Error 4012

If an error code 4012 appears when you trying to start DFS replication, this means that the replication has not been performed for too long.

The DFS Replication service stopped replication on the folder with the following local path: C:\path. This server has been disconnected from other partners for 70 days, which is longer than the time allowed by the MaxOfflineTimeInDays parameter (60). DFS Replication considers the data in this folder to be stale, and this server will not replicate the folder until this error is corrected.

You can increase this period from 60 days (default) to 120 using PowerShell:

  1. Check the current value of MaxOfflineTimeInDays:
    Get-WmiObject -Namespace root\microsoftdfs -Class DfsMachineConfig | fl MaxOfflineTimeInDays
  2. Increase it up to 120 days:
    Set-WmiInstance -Namespace root\microsoftdfs -Class DfsMachineConfig -Arguments @{MaxOfflineTimeInDays=120}
  3. Restart DFS Services.

DFS Replication Error 2104

If replication fails, with the event ID 2104 error:

The DFS Replication service failed to recover from an internal database error on volume D:\. Replication has been stopped for all replicated folders on this volume.

In this case, you need to fix the broken DFS database. Follow these steps:

  1. Disable group replication (DFS Management > Replication > Replication group > Connections);
  2. Create and run the following .bat script with administrator permissions:
    set DFS_DRIVE=E:
    net stop dfsr
    icacls "%DFS_DRIVE%\System Volume Information" /grant "Domain Admins":F
    cd "%DFS_DRIVE%\System Volume Information"
    move DFSR %DFS_DRIVE%\DFSR_backup
    cd ..
    icacls "%DFS_DRIVE%\System Volume Information" /remove:g "Domain Admins"
    net start dfsr
    dfsrdiag PollAD /Member:%userdomain%\%computername%
Cyril Kardashevsky

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.