Subscribe to Windows IT Pro
March 26, 2001 12:00 AM

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

Windows IT Pro
InstantDoc ID #20134
Rating: (1)
Downloads
20134.zip

Permitting Fallback
Hardware occasionally fails, and you might need to fall back to the old system. You can use RobocopyDataMigration.bat to copy files from the new array back to the old array. That way, you can quickly revert back to the old drives yet provide current user data.

Adapting the Script
You can find RobocopyDataMigration.bat in the Code Library on the Windows Scripting Solutions Web site (http://www.winscriptingsolutions.com). Here are the steps to modify the script for your environment:

  1. Configure the pathname for the log. In the line
  2. Set LOGLOC=C:\temp

    replace C:\temp with your log's pathname.

  3. Configure the pathname to the resource kit, if necessary. If you've installed the NT resource kit properly, the NT resource kit created an environment variable called NTResKit. To determine whether you have this variable, type
  4. Set

    at the command line. If the variable NTResKit appears in the list of variables, you don't need to set a pathname and can skip this step. If you don't see this variable or you've installed the Win2K resource kit, you need to set a pathname. Add the line

    Set NTRESKIT=C:\ntreskit

    where C:\ntreskit is your resource kit's pathname. (The script specifies where to add this line.) If you've installed the Win2K resource kit, check to see whether the folder name has spaces. If it does, consider reinstalling the resource kit into a folder whose name has no spaces.

  5. Configure the pathname for the source folder. In the line
  6. Set SOURCE=E:\test\

    change test to your source folder's name. Be sure to retain the last backslash. (The pathname must end with a backslash.)

  7. Configure the pathname for the destination folder. In the line
  8. Set DESTINATION=F:\test\

    change test to the name of your destination folder. Be sure to retain the last backslash.

  9. Configure the top-level folders. In the code that Listing 2 shows, replace Sales Marketing Managers Accounting "Human Resources" Users with the names of your top-level folders. If a folder name includes a space, enclose that name in double quotes. As a general rule, minimize spaces in top-level folders if possible.


  10. Run the script in a user context that has the necessary permissions to read from the source area and write to the destination area. If you use Task Scheduler to run RobocopyDataMigration.bat, confirm that you're running the script in a user context that has the correct permissions.

A Good Example
As RobocopyDataMigration.bat illustrates, sometimes a script has to do more than perform a task to ensure the success of a major IT undertaking. In the case of RobocopyDataMigration.bat, the script had to create detailed logs, verify results, predict downtime, and permit graceful fallback.

Related Content:

ARTICLE TOOLS

Comments
  • JOSEPH
    4 years ago
    Feb 12, 2008

    This is CRAZZY!!! We should not have to give Microsoft another $80.00 to finish reading these import articles. I paid once, that should be enough!

  • Dick Lewis
    11 years ago
    Oct 24, 2001

    I have been using Robocopy for several years but it is a little vague in my mind when different features were introduced. I think the last major change was when the /SEC switch was added, but even on this upgrade, I can't recall the version number when it changed.



    The best way to determine whether a utility will support the operations in a script is to run the command with no switches or with a "/?" to get the online help and see if the command syntax you are getting ready to use is supported in the version you have. Robocopy in its current version uses the switch "/???" to access the online help. Another way to test this particular Robocopy script with your slightly older version is to just set up a test source and destination directory and run the script against it. If you are using unsupported commands, the script will exit with an error the minute it hits the Robocopy command and will list the unsupported switch.

  • Wolf-Karsten Heintel
    11 years ago
    May 29, 2001

    Great article! It covers EXACTLY what I need within a customer data migration project.



    But I got a technical question! In my environment, there´s only Robocopy v. 1.70 available and I wonder if the .bat will work with this release as well. Could you please forward the question to Dick Lewis? That´d be greatly appreciated.

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

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