Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


September 2005

Add Robocopy to Your Toolbelt

The Ginzu knife of file copy, backup, and transfer
RSS
Subscribe to Windows IT Pro | See More Resource Kit Articles Here | Reprints
Or get the Monthly Online Pass—only $5.95 a month!

One of the Microsoft Windows Server 2003 Resource Kit's most versatile utilities is Robocopy (aka the Robust Copy Utility). Yes, Robocopy copies files, but before you get bored and turn the page, give this interesting utility a chance. Robocopy can handle copy operations involving huge chunks of data, and it lets you make certain specifications that other copy utilities—such as Copy and Xcopy—don't understand. For example, you can use Robocopy to copy a certain directory tree but only three levels down, and you can specify that Robocopy not use more than a third of the network bandwidth during a given copy operation.

If Robocopy has a weakness, it's syntax. The resource kit's robocopy.doc file doesn't really do anything except explain Robocopy's syntax—and it's 32 pages long. So let's dive in and check out some Robocopy basics.

Robocopy Basics
In its simplest form, Robocopy has a slight resemblance to other command-line copy tools:

robocopy <source directory> <destination directory>
   <filenames> <options>

Say I want to copy everything from the C:\stuff directory to the C:\stuffbak directory. I'd type

robocopy C:\stuff C:\stuffbak

So far, so good. That looks just like a Copy or Xcopy operation. But what if I want to copy only the text files whose names start with "s"? In Xcopy, I'd type something such as

xcopy C:\stuff\s*.txt C:\stuffbak

However, that syntax won't work with Robocopy. Instead of cramming together the source and destination directories with the file specifications and filters, Robocopy has a separate place for the latter items. To copy just the aforementioned text files, for example, you'd type

robocopy C:\stuff C:\stuffbak s*.txt

Network Considerations
So far, I've used source and destination examples that are merely local file folders, but Robocopy can also handle Universal Naming Convention (UNC) names, such as

robocopy \\marksws\myfiles \\centralserver\marksfiles

That command would copy everything in the myfiles share on the marksws machine over the network to a share named marksfiles on a machine named centralserver. Such functionality might be useful, but now that we've added networks to the mix, we'll need to worry about network reliability.

Any network copy operation can be interrupted by any of dozens of potential network problems. In many cases, network problems clear themselves up after a little while, so you need only try the operation again after a short wait. But who wants to babysit a big network file transfer? Fortunately, you can tell Robocopy to retry a copy operation after a specified number of seconds in the event of failure (with the /w:xx option), and you can specify the number of times it retries (with the /r:yy option). So, to tell Robocopy that you'd like your network file-copy job to retry as many as 13 times and to wait 30 seconds between retries, you'd type

robocopy \\marksws\myfiles \\centralserver\marksfiles
   /w:30 /r:13

If you don't specify a waiting period or a number of retries, Robocopy uses a default of 1 million retries for /r and 30 seconds for /w. In theory, then, a simple Robocopy command over an unresponsive network could take just under a year to complete (not that I've actually tested that).

Sometimes, a network copy job fails for a simple but annoying reason. For example, you might not have permission to read all the files you're trying to copy. (Such can be the case when you're trying to back up a user's profile or home directory.) If you need to back up some files but you don't have the NTFS Read permission, check to see whether you have Backup rights to the files—remember, they're not the same thing! If you do, you can use Robocopy with its /b or /zb options to back up the files. The /b option tells Robocopy to use the Backup permission, and the /zb option tells the tool to first try a standard copy operation, then try the Backup-based copy should that fail.

Just a Start
My intention here was to scratch the surface of Robocopy and tempt you to take a gander at the tool's online documentation. Next time, I'll share some more Robocopy functionality.

End of Article



Reader Comments
How about another art on Robo Copy

A little deeper maybe how to script a full copy of a directory with several words in it,s name like "My Documents" do you use quotes? Or do you truncate the name My~ ??

doc_rice21 January 24, 2006 (Article Rating: )


Good start; but there is so much to this little utility. We use it regularly to move user data around a 10K user network (migrations, SAN re-allocation etc.) in blocks typically of 50Gb+.
There are also caveats! - one that comes to mind is the disaster you can cause using the Mirror option... as a colleage discovered.
So maybe a pitfalls article :)

robtheailean January 25, 2006 (Article Rating: )


Your site is the MOST complicated site I have ever seen. Why don't you make a simple site to navigate and read???????

vishantpatel August 10, 2006 (Article Rating: )


I'm having difficulty using this tool when I simply want to copy multiple data folders (up to 2 levels down) and it's NTFS permissions but not copy the files. Can you please indicate what the command line switches I should using?

Etepi November 22, 2006 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
VMware and the Future of Virtualization

What's next for virtualization and business IT? Windows IT Pro senior editor Jeff James speaks with VMware President and CEO Diane Greene on the future of virtualization technology. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

What service packs and fixes are available?

...


Windows OSs Whitepapers Replay for Exchange: Enterprise Protection and an Affordable Price

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Disaster Recovery and Backup

A Guide to Windows Certification and Public Keys

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Critical Challenges of ESI & Email Retention
Are you storing too much electronic information? Get expert legal advice and better understanding of what you are required to do as an IT professional.

Become a fan of Windows IT Pro on Facebook!
Join us on Facebook and be a fan of Windows IT Pro!

Sustainable Compliance: Are You Having a Resource Crisis?
Read this white paper to examine trends in compliance and security management and review approaches to reducing the cost and operational burden of compliance.

Rev Up Your IT Know-How with Our Recharged Magazine!
The improved Windows IT Pro provides trusted IT content with an enhanced new look and functionality! Get comprehensive coverage of industry topics, expert advice, and real-world solutions—PLUS access to over 10,000 articles online. Order today!

Get It All with Windows IT Pro VIP
Stock your IT toolbox with every solution ever printed in Windows IT Pro and SQL Server Magazine plus bonus Web-exclusive content on hot topics. Subscribe to receive the VIP CD and a subscription to your choice of Windows IT Pro or SQL Server Magazine!



Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.
Windows IT Pro Home Register About Us Affiliates / Licensing Media Kit Contact Us/Customer Service  
SQL Connected Home IT Library SuperSite FAQ Wininfo News
Europe Edition Office & SharePoint Pro Windows Dev Pro Windows Excavator 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing