How to Configure DFS Replication for File Server Redundancy on Windows Server 2012 R2
Distributed File System Replication (DFSR) is a built-in Windows Server 2012 R2 technology that provides multi-master, high-efficiency file replication between two or more servers. Unlike earlier FRS-based replication, DFSR uses the Remote Differential Compression (RDC) algorithm to replicate only changed portions of files (block-level delta), dramatically reducing replication bandwidth. DFSR is used for file server redundancy, branch office file distribution, and as the underlying replication mechanism for SYSVOL in Active Directory domains running at the Windows Server 2008 R2 or higher functional level. This guide covers deploying a two-member replication group with namespace integration for transparent failover.
Prerequisites
Two or more Windows Server 2012 R2 servers joined to the same Active Directory domain. The DFS Replication role service must be installed on all participating servers. Network connectivity between replication members with sufficient bandwidth for the initial sync and ongoing replication. The DFS Management tools are required on the server from which you will manage the deployment. Both servers must be reachable on TCP/UDP port 445 and the ephemeral range used by RPC. Replication schedule planning is recommended before deployment.
Step 1: Install DFS Replication Role Service
Install the DFS Replication service on both servers using PowerShell:
# Run on each server that will participate in replication
Install-WindowsFeature FS-DFS-Replication -IncludeManagementTools
# Install DFS Namespaces as well for namespace integration (optional but recommended)
Install-WindowsFeature FS-DFS-Namespace -IncludeManagementTools
Verify installation on both servers:
Get-WindowsFeature FS-DFS-Replication | Select-Object Name, InstallState
Step 2: Create a Replication Group
Use the DFS Management console (dfsmgmt.msc) or PowerShell to create a replication group. In the DFS Management console, right-click Replication and select New Replication Group. Choose Multipurpose replication group for general file replication between servers.
Name the replication group (e.g., FileServerReplication) and add it to the correct domain. Add both member servers to the replication group.
Creating the replication group via PowerShell (requires the DFSR PowerShell module, which is part of RSAT):
Import-Module DFSR
# Create replication group with two members
New-DfsReplicationGroup -GroupName "FileServerReplication" -Description "Production file server replication"
Add-DfsrMember -GroupName "FileServerReplication" -ComputerName "FILESERVER01"
Add-DfsrMember -GroupName "FileServerReplication" -ComputerName "FILESERVER02"
Step 3: Configure Replicated Folders
Add the folders to be replicated. Designate one member as the primary member (the source for initial sync). The folder being replicated must exist on the primary member before adding it:
# Add replicated folder
Add-DfsrReplicatedFolder -GroupName "FileServerReplication" -FolderName "SharedData" -Description "Shared data replication"
# Set the local path on each member
Set-DfsrMembership -GroupName "FileServerReplication" -FolderName "SharedData" -ComputerName "FILESERVER01" -ContentPath "D:SharedData" -PrimaryMember $true -StagingPathQuotaInMB 4096
Set-DfsrMembership -GroupName "FileServerReplication" -FolderName "SharedData" -ComputerName "FILESERVER02" -ContentPath "D:SharedData" -PrimaryMember $false -StagingPathQuotaInMB 4096
Step 4: Configure Replication Connections
Create bidirectional replication connections between members. DFSR requires explicit connection objects defining the topology:
# Create connection from FILESERVER01 to FILESERVER02
Add-DfsrConnection -GroupName "FileServerReplication" -SourceComputerName "FILESERVER01" -DestinationComputerName "FILESERVER02"
# Create return connection (bidirectional replication)
Add-DfsrConnection -GroupName "FileServerReplication" -SourceComputerName "FILESERVER02" -DestinationComputerName "FILESERVER01"
For hub-and-spoke topologies with multiple branch office servers, create connections from the hub to each spoke but not between spokes directly to reduce replication overhead.
Step 5: Configure Replication Schedule and Bandwidth
Configure the replication schedule to limit bandwidth during business hours. The default schedule replicates continuously with no bandwidth limit:
# View current schedule
Get-DfsrConnectionSchedule -GroupName "FileServerReplication" -SourceComputerName "FILESERVER01" -DestinationComputerName "FILESERVER02"
# Set a schedule that uses full bandwidth 6PM-8AM weekdays and all weekend,
# and limits to 256 Kbps during business hours (8AM-6PM weekdays)
# Schedule is a 7-day x 24-hour matrix
$schedule = New-DfsrSchedule -UseUtc
# Limit bandwidth during business hours on weekdays
# (This requires custom schedule configuration via DFS Management GUI for granular control)
# Alternatively, set bandwidth limit on the connection
Set-DfsrConnectionSchedule -GroupName "FileServerReplication" -SourceComputerName "FILESERVER01" -DestinationComputerName "FILESERVER02" -ScheduleType UseGroupSchedule
Step 6: Monitor Replication Status
After configuration, monitor the initial synchronisation and ongoing replication health:
# Check replication backlog (files waiting to replicate)
Get-DfsrBacklog -GroupName "FileServerReplication" -FolderName "SharedData" -SourceComputerName "FILESERVER01" -DestinationComputerName "FILESERVER02" -Verbose
# Get replication state for all members
Get-DfsrState -GroupName "FileServerReplication" -ComputerName "FILESERVER01"
# Check for replication errors in the DFS Replication event log
Get-WinEvent -LogName "DFS Replication" -MaxEvents 50 | Where-Object {$_.LevelDisplayName -in "Error","Warning"} | Select-Object TimeCreated, LevelDisplayName, Message | Format-List
The DFSR event log (DFS Replication) is the primary diagnostic source. Key event IDs: 4112 (Initial sync started), 4104 (Initial sync completed), 2104 (Replication error), 1202 (Service started).
Step 7: Create a DFS Namespace for Transparent Access
Combine DFSR with DFS Namespaces to provide a single UNC path that clients use to access the replicated share, with automatic failover if one server becomes unavailable:
# Create a domain-based DFS namespace
New-DfsnRoot -Path "\yourdomain.comSharedData" -TargetPath "\FILESERVER01SharedData" -Type DomainV2
# Add the second server as a folder target
New-DfsnFolderTarget -Path "\yourdomain.comSharedData" -TargetPath "\FILESERVER02SharedData"
# Configure referral ordering (parallel for load balancing)
Set-DfsnRoot -Path "\yourdomain.comSharedData" -EnableTargetFailback $true
Set-DfsnFolderTarget -Path "\yourdomain.comSharedData" -TargetPath "\FILESERVER01SharedData" -ReferralPriorityClass siteCost-high
Set-DfsnFolderTarget -Path "\yourdomain.comSharedData" -TargetPath "\FILESERVER02SharedData" -ReferralPriorityClass siteCost-low
Step 8: Test Failover and Replication
Create a test file on FILESERVER01 and verify it appears on FILESERVER02 within the expected replication interval:
# Create test file on primary server
New-Item -Path "D:SharedDataDFSRTest_$(Get-Date -Format 'yyyyMMddHHmmss').txt" -ItemType File -Value "DFS replication test"
# Check backlog - should decrease as file replicates
Start-Sleep -Seconds 30
Get-DfsrBacklog -GroupName "FileServerReplication" -FolderName "SharedData" -SourceComputerName "FILESERVER01" -DestinationComputerName "FILESERVER02"
# Verify file exists on destination
Get-ChildItem "\FILESERVER02D$SharedData" -Filter "DFSRTest_*.txt"
Summary
DFSR on Windows Server 2012 R2 provides a robust, bandwidth-efficient mechanism for keeping file shares synchronised across multiple servers. Combined with DFS Namespaces, it delivers transparent failover so clients are automatically redirected to an available server when one becomes unreachable. Proper monitoring of replication backlog, staging area usage, and event logs ensures replication remains healthy and any issues are caught before they accumulate into large catch-up synchronisation tasks.