Wednesday, August 22, 2007

How to use robocopy to mirror two folders

There are many cases that we need two or more folders to be synchronized, or replicated, or mirrored, for the purpose of load sharing, redundancy and backup. One obvious example is to help standalone DFS (Distributed File System) to replicate files among the redundant folders.

In Windows 2000 Resource Kit there is a command line utility called robocopy.exe. This program can synchronize the source and destination folders by deleting the deleted source files and only copying the newer files. It can also copy files recursively. Below is a simple batch file we can use to provide the simplest one-way mirroring:

net use \\host1\share1 password1 /USER:user1
net use \\host2\share2 password1 /USERS:user2
robocopy \\host1\share1 \\host2\share2 /MIR
net use \\host1\share1 /DELETE
net use \\host2\share2 /DELETE

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home