You are currently offline, waiting for your internet to reconnect

Alternatives to the Directory Replicator Service

This article was previously published under Q160513
This article has been archived. It is offered "as is" and will no longer be updated.
Microsoft Windows NT provides a service that is designed to replicate logonscripts between domain controllers in a domain. Logon scripts were firstintroduced with the Microsoft LAN Manager product, and, although Windows NTprovides peer-level server capabilities and user profiles that provide farmore configurability of the desktop and user settings, logon scriptreplication is still supported for command-line execution and down-levelclients.

The alternatives mentioned in this article resolve several issues with theReplicator service, such as:
  • An arbitrary number of parent directories can be exported.
  • Very large file and directory synchronizations can be replicated, which may have overwhelmed the directory replicator service.
  • Exclusive access is not needed to the entire directory so a process such as File Manager or Explorer will not interfere with replication simply by having a window open in the Export directory.
The Microsoft Resource Kit provides a robust copy utility calledRobocopy.exe. This utility can be used for very large transfers andsynchronizations with large amounts of data and individual files. Thiscommand can be launched in several ways, and below are some methods thatcan be used as alternatives to the Replicator service.

For more information on the Robocopy.exe command, see the online help (type"robocopy /?") and the Robocopy.wri file included in the Resource Kit.Below is a summary of the syntax used in this document.

ROBOCOPY v 1.54 : Robust File Copy for Windows NT

Usage : ROBOCOPY source destination [file [file]...] [options]
source : Source Directory (drive:\path or \\server\share\path).
destination : Destination Dir (drive:\path or \\server\share\path).
file : File(s) to copy (names/wildcards - default is "*.*").
/S : copy Subdirectories, but not empty ones.
/E : copy subdirectories, including Empty ones.
/R:n : number of Retries on failed copies - default is 1 million.
/W:n : Wait time between retries - default is 30 seconds.
/REG : Save /R:n and /W:n in the Registry as default settings.
/X : report all eXtra files, not just those selected.
/V : produce Verbose output, showing skipped files.
/L : List only - don't copy, timestamp or delete any files.
/ETA : show Estimated Time of Arrival of copied files.
/MOVE : Move files and dirs (delete from source after copying).
/PURGE : delete dest files/dirs that no longer exist in source.

Method 1

A batch file can be created and simply run when changes have been made tothe source files and synchronization is needed between the domaincontrollers. An example of such a batch file is below. Because of word-wrap, each grouping of lines is actually one line in the ASCII BAT file.
   robocopy \\<computer1>\admin$\system32\repl\export\    \\<computer1>\admin$\system32\repl\import /s /v /r:1 /w:1 /eta   robocopy \\<computer1>\admin$\system32\repl\export\    \\<computer2>\admin$\system32\repl\import /s /v /r:1 /w:1 /eta				

NOTE: <computer1> and <computer2> are the names of the computers beingsynchronized.

Method 2

The above BAT file can be made to run in a loop, pausing for a specifiedamount of time between each copy. Another Resource Kit utility calledSleep.exe can be used to specify the number of seconds for the delaybetween synchronizations. This BAT file could be placed in the Startupgroup, always run, and minimized on the desktop. To ensure access to eachremote domain controller, Sleep.exe should be run under the user context ofan administrator. Below is an example of such a BAT file. Because of word-wrap, each grouping of lines is actually one line in the ASCII BAT file.
   :loop   robocopy \\<computer1>\admin$\system32\repl\export   \\<computer1>\admin$\system32\repl\import /s /v /r:1 /w:1 /eta   robocopy \\<computer1>\admin$\system32\repl\export   \\<computer2>\admin$\system32\repl\import /s /v /r:1 /w:1 /eta   sleep 1800   goto loop				

NOTE: <computer1> and <computer2> are the names of the computers beingsynchronized.

If file permissions must be maintained on the files, use SCOPY, anotherresource kit utility. As Robocopy is more robust, Scopy could be used forthe initial replication of NTFS permissions, and then Robocopy can be usedfor the regular replication, if the permissions are not changed on aregular basis and the directory tree structure is fairly static.

If less granular permissions are acceptable, move away from NTFS filesecurity and towards the lower granular security implemented with sharepermissions. This may reduce the amount of administration required andeliminate the need for replicating file permissions.

Method 3

Another method to maintain directory structures remotely can be to schedulea batch file using the Scheduler service. Services provide the benefit ofallowing for synchronization independent to the user logged on, and when auser is logged on, there is no minimized icon that could be accidentallyterminated. As with any access to a remote machine over the network, theuser-context of the process must have the necessary read or writepermissions. To do this, the Scheduler service needs to be started with auser account instead of the local system account. If more than onesynchronization is desired each day, each occurrence requires a separatestatement. The BAT file presented in Method 1 above can be used as anexample, and the following statements can be used to configure theScheduler service to establish synchronization at the desired intervals.
   AT 12:00AM /every:m,t,w,th,f,sa,su c:\bin\replicate.bat   AT 08:00AM /every:m,t,w,th,f,sa,su c:\bin\replicate.bat   AT 12:00PM /every:m,t,w,th,f,sa,su c:\bin\replicate.bat   AT 08:00PM /every:m,t,w,th,f,sa,su c:\bin\replicate.bat				

With the /every switch, the Scheduler service records the frequency andinitiates the jobs with no more administrator intervention.

To verify the status of the Scheduler service, type AT at the commandprompt.

To test the BAT file with the Scheduler service, the /interactive switchcan be use to see output from Robocopy, or the output can be redirected toa file as mentioned below.

Method 4

In the interest of completeness, one final method can be discussed. The BATfile displayed in Method 2 above, which uses the SLEEP command to regulatethe synchronization interval, can be launched as a user created service.This provides the usual benefits of running as a service, and also thebenefit of there being a single thread of execution with the single BATfile. Although unlikely, if the Scheduler service were used to regulate theinterval instead of the SOON command, and if Robocopy were to fail duringthe file synchronization, launched processes could accumulate withoutcompleting, as the Scheduler service does not track launched processesafter they are run. The BAT file in Method 2 could be used along with theInstsrv.exe command to create the registry entries for the Srvany.exeservice from the Resource Kit. See online help and the Resource Kit Helpfile for the particular syntax and instruction.

Robocopy Notes

  • The /purge command can be used to delete files on the destination server that have been deleted from the source server. This is the behavior of the replicator service. Use this switch with caution because it deletes data.
  • If the destination files you are trying to replicate are often in an open state, you may want to limit the default number of retires Robocopy will try when copying these files. Using the switches "/R:5 /W:5" will timeout more quickly.
  • Robocopy displays very detailed output that administrators may find useful and want to save to a file. This output can be redirected to a file by appending the following symbolic path to each ROBOCOPY statement: ">>drive:\directory\filename.txt." In a relatively short time, this may create a very large file. Even if few changes occur on the source server and synchronization checks occur every 30 minutes, this file can grow to an estimated size of about 4.5 MB in only a month. This assumes that 3 KB of information is written for each replication attempt, and the verbose switch is not used.
  • Unlike the Replicator service, Robocopy does not have to run on the server where the source files are located.
  • If absolute symmetry is needed between the source and destination directory structure, the /purge, /e, /t, and event /is switches can be used. This level of duplication is probably not necessary. See the online help and the Robocopy.wri file for more details.

Article ID: 160513 - Last Review: 12/04/2015 15:52:26 - Revision: 2.1

Microsoft Windows NT Workstation 3.5, Microsoft Windows NT Workstation 3.51, Microsoft Windows NT Workstation 4.0 Developer Edition, Microsoft Windows NT Server 3.5, Microsoft Windows NT Server 3.51, Microsoft Windows NT Server 4.0 Standard Edition

  • kbnosurvey kbarchive kbenv KB160513