Using Robocopy to mirror directories

I had to copy the contents of a drive on an XP box to another network drive (which was actually a FreeNAS box) on my LAN yesterday (part of a longer story involving a crashed backup disk – but that’s a tale for another time). It was over my LAN network and involved a zillion files. So I wanted:

  1. Copy entire directories
  2. Per-file progress feedback since some of the files are big
  3. The fasted protocol possible. Since it was going to a NAS I could try copying over SSH, FTP, and TFTP in addition to simple Windows share copying (SMB).
  4. Resumability of transfers
  5. Must run on XP. I came across RichCopy, which is a multithreaded successor to RoboCopy, which actually works pretty well. In my case though it wouldn’t help me since I am bandwidth-constrained more than anything else.

I tried a number of ways to do this, namely:

  1. FTP – couldn’t get the server working on FreeNAS (apparently due to a DHCP-related bug)
  2. TFTP – the Windows client doesn’t look like it can do whole directories, only single files at a time
  3. SSH – works but is dog-slow (I was getting about 150KB/s on my LAN)
  4. Simple drag-and-drop copying over SMB – kept crapping out unexplainably.

So in the end I went with Robocopy, a free command-line tool from Microsoft. Built into Vista, you can install it from the Windows Server 2003 Resource Kit on XP. The simple command was:

robocopy c:\source\path\to\dir z:\dest\path\to\dir /mir /zb

Make sure your destination path doesn’t exist first. If you cancel out and run it again it picks up where it left off which is nice.

It wasn’t particularly fast, but at least it wasn’t as slow as SSH.

Leave a comment

Your email address will not be published. Required fields are marked *