Leaderboard (728 x 90)

Wednesday, January 20, 2010

Windows File Replication with robocopy

A better way to replicate is to use the ROBOCOPY utility from the resource kit tools.

There are at least 4 ways that you can use ROBOCOPY to do your replication:

1. A manually invoked batch file:


robocopy \\\admin$\system32\repl\export\ \\\admin$\system32\repl\import /s /v /r:1 /w:1 /eta
robocopy \\\admin$\system32\repl\export\ \\\admin$\system32\repl\import /s /v /r:1 /w:1 /eta
NOTE: and are the names of the computers being synchronized.

The first time that you replicate, use SCOPY to preserve permissions and then use ROBOCOPY which will maintain the permissions.

2. You can cause the above batch file to continuously loop:


:LOOP
robocopy \\\admin$\system32\repl\export\ \\\admin$\system32\repl\import /s /v /r:1 /w:1 /eta
robocopy \\\admin$\system32\repl\export\ \\\admin$\system32\repl\import /s /v /r:1 /w:1 /eta
Sleep 1800
goto LOOP
Sleep is a Resource Kit utility. The above sleeps for 1800 seconds, ½ hour.

3. Schedule the batch file from number 1.

The schedule service runs under the context of the system account which is local and has no network access. Create a new user account that is a member of the domain admin group with a non-blank, non-expiring password. In user manager for domains, give it all the advanced rights it may ever need including logon as a service and batch job.

In control panel services, stop the schedule service. Configure it to start automatically and to use this new account. Start the scheduler service.

AT 12:00AM /every:m,t,w,th,f,sa,su \Folder\replicate.bat
AT 08:00AM /every:m,t,w,th,f,sa,su \Folder\replicate.bat
AT 12:00PM /every:m,t,w,th,f,sa,su \Folder\replicate.bat
AT 08:00PM /every:m,t,w,th,f,sa,su \Folder\replicate.bat

4. Run it as a service

You can use the batch file from number 2 and Instsrv.exe to create the regiistry entries for the SRVANY service. These utilites are also from the Resource Kit.

NOTES:

You use the /purge option to delete files on the destination that have been removed from the source if you wish to emulate this replicator service function.

You may wish to limit the default retries as the destination files may be in an open status. Using /R:5 /W:5 will timeout faster.

If you pipe the output, check that your log file isn't consuming too much space.

You can run ROBOCOPY on any machine, even a Workstation. It does not have to run on the source or destination computer.

If absolute symmetry between the source and destination directories is needed, the /purge, /e, /t, and event /is switches can be used. See the online help and the Robocopy.wri file, you may not need to be this exacting.

Reference: http://windowsitpro.com/article/articleid/71934/jsi-tip-0609---a-better-way-to-replicate.html

No comments:

Post a Comment