MORE INFORMATION
The Microsoft Resource Kit provides a robust copy utility called
Robocopy.exe. This utility can be used for very large transfers and
synchronizations with large amounts of data and individual files. This
command can be launched in several ways, and below are some methods that
can 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 to
the source files and synchronization is needed between the domain
controllers. 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 being
synchronized.
Method 2
The above BAT file can be made to run in a loop, pausing for a specified
amount of time between each copy. Another Resource Kit utility called
Sleep.exe can be used to specify the number of seconds for the delay
between synchronizations. This BAT file could be placed in the Startup
group, always run, and minimized on the desktop. To ensure access to each
remote domain controller, Sleep.exe should be run under the user context of
an 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 being
synchronized.
If file permissions must be maintained on the files, use SCOPY, another
resource kit utility. As Robocopy is more robust, Scopy could be used for
the initial replication of NTFS permissions, and then Robocopy can be used
for the regular replication, if the permissions are not changed on a
regular basis and the directory tree structure is fairly static.
If less granular permissions are acceptable, move away from NTFS file
security and towards the lower granular security implemented with share
permissions. This may reduce the amount of administration required and
eliminate the need for replicating file permissions.
Method 3
Another method to maintain directory structures remotely can be to schedule
a batch file using the Scheduler service. Services provide the benefit of
allowing for synchronization independent to the user logged on, and when a
user is logged on, there is no minimized icon that could be accidentally
terminated. As with any access to a remote machine over the network, the
user-context of the process must have the necessary read or write
permissions. To do this, the Scheduler service needs to be started with a
user account instead of the local system account. If more than one
synchronization is desired each day, each occurrence requires a separate
statement. The BAT file presented in Method 1 above can be used as an
example, and the following statements can be used to configure the
Scheduler 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 and
initiates the jobs with no more administrator intervention.
To verify the status of the Scheduler service, type AT at the command
prompt.
To test the BAT file with the Scheduler service, the /interactive switch
can be use to see output from Robocopy, or the output can be redirected to
a file as mentioned below.
Method 4
In the interest of completeness, one final method can be discussed. The BAT
file displayed in Method 2 above, which uses the SLEEP command to regulate
the synchronization interval, can be launched as a user created service.
This provides the usual benefits of running as a service, and also the
benefit of there being a single thread of execution with the single BAT
file. Although unlikely, if the Scheduler service were used to regulate the
interval instead of the SOON command, and if Robocopy were to fail during
the file synchronization, launched processes could accumulate without
completing, as the Scheduler service does not track launched processes
after they are run. The BAT file in Method 2 could be used along with the
Instsrv.exe command to create the registry entries for the Srvany.exe
service from the Resource Kit. See online help and the Resource Kit Help
file 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.