DFS Replication monitoring it's very important task for every IT Pro which use it because we can avoid data loss or unexpected replications that we don't want.
In previous article describe How to install and configure DFS Replication in Windows Server 2016 to create a Disater Recovery solution for your File Server or when have Branches and you need to keep your File Servers sync with the same date in all your Branches.
To be honest monitoring it's not an easy task but if you keep the Best Practices and frequently get the DFS Replication Status then the job will be easier.
Download a PDF guide with the Best Practices in File Servers that use DFS Replication to avoid data loss
Now that you have install DFS Replication in both File Servers what next?
I can't cover all the issues and failed scenarios that maybe appear in every environment but can guide you to prevent lot of replication issues in the following steps
How to check DFS Replication Status
Which are the components to check for the replication status?
Unfortunately Microsoft didn't create a centralize tool for the DFS Replication. Also you must know that DFS Replication will not include any new features because Storage Replica it's a new Feature with more advantages.
To keep healthy DFS Replication must be monitoring and resolve as soon as possible errors from the followings:
- Event Viewer Logs
- Backlogs Status
- Health Reports from Event Management.
Let's go to explain step by step how can monitoring the above
How to check Event Viewer Logs for DFSR errors
All we know how can check logs from Event Viewer.
Also all we know that lot of times we don't give attention in Event Viewer Logs because of a high workload as IT Pro or we schedule to check logs once a week to identify issues.
I am the IT Pro that prefer to schedule once a week to check Logs and identify problems that appears or take decisions to be proactive.
But this is not a solution for File Servers with DFS Replication. It's very important to check every day Event Viewer Logs for Warning or Errors related with DFS Replication
- Open Event Viewer
- Expand Application and Services Logs
- Click in DFS Replication to find all the logs related with DFSR.
- Find out lot of Warnings that i created intentionally just to see errors and not only Informational Logs
How to check Replication Status with DFS Management from Health Reports
After check dfs replication logs from Event Viewer it's recommended to create a Health Report from DFS Management.
- From Server Manager click in Tools -- DFS Management
- From the right side click Create Diagnostic Report
- Select Health Report. Click Next
- Select where do you want to export the Report. Click Next
- Include all the members. Click Next
- It is a must to select Yes count backlogged files in this report.
- Select the Reference Member. It is the Server tat has the latest version of the files. This is depends from you.Click Next
- Click Create.
- Wait a few seconds until create the HTML Report that you can see what happened in your File Servers.
- Expand the WARNINGS or ERRORS to read what's going on
- Health Reports has a good Reporting but you can't cover if you need in depth details. You can get the status but after that you must use other tools to see exactly what's going on.
- Following i will describe some tools that can use it when you need more details with the Replication Logs.
How to check Backlogs with Powershell
I can't say that the previous aren't important but Backlogs it's also very important to check it every day.
Backlogs are the files that wait to replicate in the partner.
So if you find suddenly lot of backlogs without did any big change then it's a signal that something going wrong with your replication.
Then your next step is to search deeper from Health Reports and Event Viewer Logs what's going on.
How can get the Backlogs with powershell?
- Open Powershell as Administrator
- Type the following command and change SourceComputername and DestinationComputername
Get-DfsrBacklog -SourceComputerName flsrv01 -DestinationComputerName flsrv02
- If you need a report that can read easier then type
- Select fields that full fill your requirements.
- In this example you can see that i have few files that wait for replication.
Get-DfsrBacklog -SourceComputerName flsrv01 -DestinationComputerName flsrv02 | select FileName,FullPathName
If you need more details go in Microsoft Docs for Get-DfsrBacklog
How to compare replicated folders for different files
Every time that i had setup a DFS Replication between File Servers i have the following question:
How do i know that all files are replicated correctly despite the successful Health Reports ?
I found a very useful example in Microsoft Docs that explain how can compare the File Hashes between replicated folders.
So let's take a look and explain some details to keep the script for emergency situations or just to do a check.
Before begin the explanation i would like to know that we will use the powershell command Get-DfsrFileHash which compare the File Hashes between the files or folders
So first of all we must map a network drive with the folder that we want to check.
net use h: \\flsrv01\<folder>\*
Export the file hashes from the files is a txt file
Get-DfsrFileHash h:\* | Out-File C:\Srv01.txt
Disconnect the map drive
net use h: /d
Create a new map drive with the same Letter. This detail its very important. If you map a network drive with different letter then you will have all the files as different.
net use h: \\flsrv02\<folder>\*
Export the file hashes from the files in different txt file
Get-DfsrFileHash h:\* | Out-File C:\Srv02.txt
Disconnect the map drive
net use h: /d
Compare the file hashes between the 2 files and get results which are different. The parameter -IncludeEqual you can ignore it if you want to see only the different files.
It seems that my replication status it's Healthy.
Compare-Object -ReferenceObject (Get-Content C:\Srv01.txt) -DifferenceObject (Get-Content C:\Srv02.txt) -IncludeEqual
Find out the same report but with different letter in map drive. If you check the FileHashes are the same for the files but the comparison it's show as not equal
Good Monitoring and take care of you
Have a nice weekend !!