Use Robocopy to Preseed Files for DFS Replication

I’ll write this here first, since it’s important: The folder in which you are robo-copying (ex c:\test) must not exist on the destination server (ex. f:\test).

  • If you create the folder manually on the destination server, the file-hashes will not match and DFSr will see a conflict. So make sure your destination (ex. f:\ ) doesn’t contain a folder named the same as the source folder.

Pre-seeding your DFS Replication Group with Robocopy:

  1. Log on to the destination server with an Administrator account.

  2. Open an elevated command prompt or Powershell.

  3. Copy files from source to destination using the following command, substituting your own source, destination, and log file paths.

robocopy "<source replicated folder path>" "<destination replicated folder path>" /e /b /copyall /r:6 /w:5 /MT:64 /xd DfsrPrivate /tee /log:<log file path> /v

This command copies all contents of the source folder to the destination folder, and in all cases it should be creating the destination folder as well.

Here is an explanation of the parameters from the example above:

Parameter Description
“<source replicated folder path>” Specifies the source folder to preseed on the destination server.
“<destination replicated folder path>” Specifies the path to the folder that will store the preseeded files.

Important
The destination folder must not already exist on the destination server. To get matching file hashes, Robocopy must create the root folder when it preseeds the files.
/e Copies subdirectories and their files, as well as empty subdirectories.
/b Copies files in Backup mode.
/copyall Copies all file information, including data, attributes, time stamps, the NTFS access control list (ACL), owner information, and auditing information.
/r:6 Retries the operation 6 times when an error occurs.
/w:5 Waits 5 seconds between retries.
MT:64 Copies 64 files simultaneously.
/xd DfsrPrivate Excludes the DfsrPrivate folder.
/tee Writes status output to the console window, as well as to the log file.
/log <log file path> Specifies the log file to write. Overwrites the file’s existing contents. (To append the entries to the existing log file, use /log+ <log file path>.)
/v Produces verbose output that includes skipped files.

There are other parameters which are not used in this example. If you will replicate larger files primarily, you might be able to increase copy performance by adding the /j option for unbuffered I/O. You may also increase the thread count if you find out through testing that you have the capacity to set a higher value (thread count) for the /MT parameter.

For more information about Robocopy parameters, see the Robocopy command-line reference.

Example:

The following command replicates the root folder and files from the source replicated folder E:\RF01 on SERVER01 to data drive D: on the destination server, SERVER02:

robocopy.exe "\\SERVER01\e$\RF01" "d:\RF01" /e /b /copyall /r:6 /w:5 /MT:64 /xd DfsrPrivate /tee /log:c:\temp\preseed-server02.log
  • It is important to note that this method is ran interactively on the destination server, where it is accessing SERVER01’s E: drive over SMB and copying the files locally.
  • This is the way I prefer using robocopy, rather than specifying a remote destination which seems rather unsettling.

To avoid potential data loss when you use Robocopy to preseed files for DFS Replication

Do not make the following changes to the recommended parameters:

  • Do not use the /mir parameter (which mirrors a directory tree) or the /mov parameter (which moves the files, and then deletes them from the source).
  • Do not remove the /e, /b, and /copyall options.

 

After copy finishes:

You will get a report at the bottom of your shell, which will look something like this:

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :      3337      3336         2         0         0         0
   Files :     30643     30643         0         0         0         0
   Bytes :  71.457 g  71.457 g         0         0         0         0
   Times :  49:19:43   0:48:02                       0:00:00   0:00:49
   Ended : Wednesday, May 3, 2017 3:34:45 PM

  Examine the log for any errors or skipped files.

  • You might see that files were skipped.
  • DFS Replication will take care of copying any files that were skipped in the robocopy, so it’s up to your judgement whether or not to keep using robocopy to transfer the remaining files or to proceed with DFSr.

Validate Files

You can use Get-DfsrFileHash cmdlet in Windows PowerShell or the Dfsrdiag filehash command to validate the preseeded files by comparing file hashes on the source and destination servers:

PS C:\Windows\system32> dfsrdiag filehash /path:d:\RF01\

   File Hash: A2F501A6-31B37955-B8BB02BD-3B52C875

Operation Succeeded

PS C:\Windows\system32> dfsrdiag filehash /path:\\SERVER01\e$\RF01\

   File Hash: A2F501A6-31B37955-B8BB02BD-3B52C875

Operation Succeeded

PS C:\Windows\system32>

 

For more detailed instructions instructions, see Validate Preseeded Files for DFS Replication.


1 Comment

vikas khandola · March 18, 2018 at 8:45 am

use robocopy

Leave a Reply to vikas khandolaCancel reply