[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


Mirror Windows files and folders with Robocopy

Published on
7,344 Points
2 Endorsements
Last Modified:
So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake.

You can use Robocopy from the Windows Server 2003 Resource kit tools to accomplish this.  (The resource kit tools can be found here:  http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en)

The following command will MIRROR a source directory with a remote directory.  Be CAUTIOUS because the following will not only copy source files over, but if source files/folders get removed it will then remove them from the remote/destination directory (hence the term "mirror").
"C:\Program Files\Windows Resource Kits\Tools\robocopy.exe" "\\SOURCESERVER\FOLDERTOMIRROR" "\\DESTINATIONSERVER\DESTINATIONFOLDER" /MIR /LOG+:"c:\robocopylogs\mirror.log.txt"

Open in new window


1. Create Log Directory

Create c:\robocopylogs to hold the log files

2. Modify command with inputs

Change the above command snippet inputs (ie. change \\SOURCEFOLDER\FOLDERTOMIRROR to reflect your source folders/files to mirror) You will need to change source and destination for your needs.  It can be a folder or files.  A folder will end up mirroring everything in that folder (files/subfolders/subfiles).

3. Run Command

Put the command into notepad and save the file as a .bat.  Then doubleclick the batch file to run the command.  The log file in the command will be appended to each time.

4. Optional: Schedule command

You can use Task Scheduler to schedule the mirror to take place daily, etc.  I won't go into Task Scheduler here though.

Example Command:
"C:\Program Files\Windows Resource Kits\Tools\robocopy.exe" \\orgdc01\shared\hc12\12common \\fwmnas\ipd\software\hc12\12common /MIR /LOG+:"c:\copylogs\cpyhc12.log.txt"

Open in new window

Example Output:

   ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010

  Started : Wed Dec 17 08:19:51 2008

   Source : \\orgdc01\shared\hc12\12common\
     Dest : \\fwmnas\ipd\software\hc12\12common\

    Files : *.*
  Options : *.* /S /E /COPY:DAT /PURGE /MIR /R:1000000 /W:30 


	                   0	\\orgdc01\shared\hc12\12common\
	                   0	\\orgdc01\shared\hc12\12common\os\
	                   5	\\orgdc01\shared\hc12\12common\os\12c128\
	                   5	\\orgdc01\shared\hc12\12common\os\12dp256\
	                   6	\\orgdc01\shared\hc12\12common\os\12dp512\
	    Newer     		     219	iosdp512.la
	                   1	\\orgdc01\shared\hc12\12common\os\can\


                Total    Copied   Skipped  Mismatch    FAILED    Extras
     Dirs :         6         0         6         0         0         0
    Files :        17         1        16         0         0         0
    Bytes :   225.3 k       219   225.1 k         0         0         0
    Times :   0:00:09   0:00:03                       0:00:00   0:00:05

    Speed :                  63 Bytes/sec.
    Speed :               0.003 MegaBytes/min.

    Ended : Wed Dec 17 08:20:40 2008

Open in new window

1 Comment

Expert Comment

by:Senior IT System Engineer
Thanks for posting man, so how to make the Robocopy skip the files and folder that already exist or created in the destination folder ?

So when I execute the same script the Robocopy app just copy the differences only ? or the deltas.

Featured Post

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Join & Write a Comment

Key to your CPU's ability to stay cool is to use the right amount of thermal paste and apply it correctly. In other words you want as much thermal conductivity between CPU and the cooling block. Use a quality thermal paste and apply it in a manner…
I've published three five-minute Experts Exchange video Micro Tutorials that describe terrific features in an excellent, free PDF product called PDF-XChange Editor: How to rotate pages in a PDF with free software (https://www.experts-exchange.com…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month