Export a Clone of the DFS Replication Database

Export a Clone of the DFS Replication Database

Here i am going to explain about DFSR new feature “Database Cloning” which is introduced in Windows Server 2012 R2.

Whenever we add a new member to the replication group for the first time, replace server hardware or recover from loss of corruption of the DFS replication database. It takes long time to do the initial synchronisation which takes long time to complete and then files and folders replication starts. By this feature, we can reduce the initial synchronisation time by up to 99% under ideal circumstances.

“Source Server” from which you will export the DFS Replication Database.
“Destination Server” on which you will import the DFS Replication Database.

Two main things to remember before you start this process on the source and destination server.
1. You can perform cloning operation at a time per server.
2. You must be “Domain Admin” or “Enterprise Admin” or have delegated permissions to work on DFSR.


Necessary requirements on source server.
1. SYSVOL and Read-Only folders are not included in the database export process.
2. Replicated folder on source computer should be in Normal State. It should not be in “Initial Sync”, “Initial Building” or “Recovery States” because they will be skipped while cloning.
3. Use only approved techniques to copy files in the replication folder of the destination server. Like: Robocopy.
4. Confirm your preseeding work by using Get-DfsrFileHash.
5. If you want cloning performance at its best. Make sure that you prevent all users to making changes to files on the source server during the cloning operation. Best time is doing it after office hours, reboot the source server before start cloning.
6. While cloning operation, replication of the replicated folder will be stopped and resume by its own after the operations gets completed.

Necessary requirements on destination server.
1. Remove <volume>:\system volume information\dfsr\database_<string> from the destination server, if it is already created on the replication folder.
2. Before import the database. Prevent users for making any new or change on the existing files on destination server. Best way is the change their sharing permission from “read-write” to “read only”.

Export DFS Replication database.
1. Check the state of all replicated folders on the volume and make sure that they all are in Normal state.
1
Get-WmiObject -Namespace "root\Microsoft\Windows\DFSR" -Class msft_dfsrreplicatedfolderinfo -ComputerName ServerName | ft replicatedfoldername,state -auto -wrap | Select-Object -Property ReplicationGroupName, State
2. Export the cloned database and volume configuration XML by running the following sample command from an elevated Windows PowerShell session.
1
2
3
4
$DfsrCloneVolume = "H:"
$DfsrCloneDir = "\DfsrClone"
New-Item -Path $DfsrCloneVolume\$DfsrCloneDir -Type Directory
Export-DfsrClone -Volume $DfsrCloneVolume -Path $DfsrCloneVolume\$DfsrCloneDir
3. After complete the cloning process. It will give two robocopy command. First to rebocopy the database and then robocopy the replicated folder. Make sure you make the note of them and use them accordingly.
1
2
Robocopy.exe "H:\DfsrClone" "<destination path>" /B 
Robocopy.exe "H:\ReplicatedFolder" "<destination path>" /E /B /COPYALL /R:6 /W:5 /MT:64 /XD DfsrPrivate /TEE /LOG+:preseed.log 
4. Export is done. You can confirm it by run the command "Get-DfsrCloneState" and it will return the "Ready" if the export process is completed. Or you can DFS Replication Event Log 2402.

Import DFS Replication database.
1. Copy the cloned database on the destination server, which will imported after some important below steps.
1
Robocopy.exe "H:\DfsrClone" "\\Srv02\H$\DfsrClone" /B
2. Use an approved method (Robocopy) to preseed the destination server with the contents of the replicated folders from the source server. If the destination server is the same as the source server then you can skip this step (It happens when you are dealing with corrupted DFSR database, replacing hardware or migrating volumes to other operating system.).
1
Robocopy.exe "H:\ReplicatedFolder" "<destination path>" /E /B /COPYALL /R:6 /W:5 /MT:64 /XD DfsrPrivate /TEE /LOG+:preseed.log 
3. Remove existing DFSR database for the replicated folder from the volume. There should not be any old DFSR database (dfsr.db) for the replicated folder which you are preseeding on the destination server.
1
2
3
Stop-Service DFSR
Remove-Item –path "H:\system volume information\dfsr" –recurse -force
Start-Service DFSR
4.After all preseeding operations are complete, import the cloned database and volume configuration XML.
1
Import-DfsrClone -Volume h: -Path "h:\Dfsrclone"
5. Wait for a DFS Replication Event 2404 in the DFS Replication event log, which indicates that the import completed successfully. Or. You can also use the Get-DfsrCloneState cmdlet to see the export status. The cmdlet returns Ready when the import process completes.
6. Add the destination server to the replication group and wait for DFS Replication event 4104 in the DFS Replication event log, which indicates that the replication folder initialized successfully as a nonauthoritative member (there is one event per replicated folder).
7. Check Backlogs to see the replication.

Any suggestions, please put them in comments.

0 comments:

Post a Comment