Perhaps this is ironic for someone who has a heavy focus on beautiful client interfaces, but I’ve always been a bit of a command-line junkie. Maybe it’s a fetish, maybe it’s just a legacy of the early DOS, VAX/VMS and UNIX systems that I used in my formative years, but I’ve always rather liked the uncluttered “get stuff done” experience of a shell.
One particularly common motivation for me to drop back to the Windows Vista command shell is to copy files. For years, robocopy has been an essential part of the Microsoft engineer’s toolkit. When I was back in the UK, it was about the only sane way to copy large file structures over the WAN from Redmond, but even now, it’s one of the most trusted and useful tools in my toolbox – the first thing I copy over onto a fresh installation to help manage everything that will follow.
Robocopy has been around as an independent tool for a little while (primarily in the Windows Resource Kits), but finally in Windows Vista, someone has seen fit to give the little tool the recognition it deserves, and as a result it now sits on a high pedestal in the \windows\system32 directory on every Windows Vista installation.
Why is robocopy so cool? Well, for starters, it’s hard to find a more flexible, configurable tool – with over 80 switches, the chances are it can handle any batch or synchronous copy you have in mind.
Secondly, it’s just very robust. If a network link goes down halfway through a lengthy copy, most tools bail out, but robocopy just patiently waits, retrying x times with a y second interval (of course, x and y are configurable). Better still, it can be configured to pick up where the file transfer left off, so you don’t have to go all the way back to the start if the network fails 99% of the way through a 2GB file.
Finally, it’s perfectly optimized for mirroring large file shares on a slow WAN link. It only copies files that have changed, which is perfect for the occasions when you want to pull down a daily build where only 30% of the files have changed since the last occasion. You can set it to monitor a source and keep the destination updated with changes on a repeated schedule. Lastly, you can even throttle the traffic down by tweaking the inter-packet gap, so that a network link isn’t monopolized by the copy process.
I use robocopy for copying new daily builds down from a central server, for backing up my personal and work files to shared locations, and simply for moving files around from partition to partition. Even as I write this, there’s a robocopy window mirroring my entire data partition to a removable USB hard drive so that I can transfer my data from one laptop to another.
If you’re not running Windows Vista already (shame on you!), you can download robocopy as part of the Windows Server 2003 Resource Kit Tools (where there’s also a user manual in Word format for the tool). If you’re not a command-line junkie, there’s a GUI wrapper available from GotDotNet, although it doesn’t really provide much more than a shell for the switches. Start with the /mir and /z switches to get a sense of the power of the tool (but be careful with /mir since it will delete as well as copy files to bring the destination folder in sync with the source folder). Run robocopy /? to see the full set of parameters available. Good luck!