Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

February 26, 2001 12:00 AM

Real-World Scripting: Data Migration with Robocopy, Part 1

Windows IT Pro
InstantDoc ID #19826
Rating: (0)
Downloads
19826.zip

Sometimes writing a script entails more than writing and testing code that performs a certain task. When a script is to perform a major IT undertaking such as data migration, you need to write a script that not only performs the task but also minimizes associated risks and downtime.

For example, my company had a file server with a shared 250GB RAID 5 array that was quickly filling up with users' files, despite ongoing efforts to remove old and obsolete files. To meet the increasing memory needs, the company purchased new disks. The IT server team installed the new disks and configured them into a 500GB RAID 5 array, which the team connected to the same file server.

I had to write a script that migrated the six top-level folders while retaining the complicated NTFS file and folder permissions. I worked with the server team that maintains the server to determine the script's requirements. We determined that the script needed to

  • Copy the entire file and folder structure from the old array to the new array while maintaining NTFS permissions


  • Create a detailed log of the migration results for each top-level folder
  • Verify the results of the copy operation


  • Determine how long the system would need to be offline for the data migration so that we could develop a strategy to minimize downtime for users


  • Permit graceful fallback if hardware failed or other unforeseen circumstances arose

RobocopyDataMigration.bat is the script I created. You can find RobocopyDataMigration.bat in the Code Library on the Windows Scripting Solutions Web site (http://www.winscriptingsolutions.com). This month and next, I'll describe how the script works and how you can adapt it for your environment.

Copying the Data
To copy the file and folder structure, RobocopyDataMigration.bat uses Robocopy 1.96. You can find Robocopy 1.96 in the Microsoft Windows 2000 Resource Kit or the Microsoft Windows NT Server 4.0 Resource Kit, Supplement 4. The pathname for the resource kit's folder depends on which version you install. RobocopyDataMigration.bat uses the default NT pathname of C:\ntreskit. The default pathname for the Win2K resource kit is C:\program files\resource kit. If you install the Win2K resource kit, though, I recommend you install it in a folder with no spaces in the name, similar to the NT default location. Using a name with spaces in a batch command can create problems when the command executes. In the past, many administrators used the workaround of enclosing such commands in double quotes. In Win2K, this workaround produces inconsistent results. Furthermore, nesting a command enclosed in double quotes within a For command can produce inconsistent results in both Win2K and NT.

Robocopy is a powerful and useful utility because of its many options, or switches. To customize RobocopyDataMigration.bat to your environment, you need to learn about these switches. To obtain a short description of them, you can run the command

Robocopy /???

at the command line to view the online Help file. (The Help switch depends on the Robocopy version. Robocopy 1.96 uses the /??? switch, but earlier versions might use a different switch.) The 22-page document robocopy.doc explains each switch in detail. (Although robocopy.doc might show 1.95 as the version number, the installed version is actually 1.96.)

Related Content:

ARTICLE TOOLS

Comments
  • Anonymous User
    7 years ago
    Mar 03, 2005

    Thanks this script saved me loads of time.

  • Brendan
    10 years ago
    Oct 17, 2002

    I need a solution. I am transferring GB of data over a WAN Link to a SAN. I have a backup tape of the data from the site. The problem is just 10 users a night out of 400 are being migrated. I need to fetch the differences in the files from the time the tape was created to the time of migration. Robocopy only does an exclude of directories, which means I need to put 390 usernames in the batch file every night, so that only the 10 people that I need are updated. This is not a solution. Can anyone help?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.