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 


February 2005

Want a Flexible Automated Backup Solution?

Overcome NTBackup’s shortcomings with these scripts
RSS
Subscribe to Windows IT Pro | See More Backup and Recovery Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

With the release of Windows 2000, Microsoft overhauled the built-in backup utility NTBackup and added media-management and scheduling capabilities. Although these updates are welcome, comments I have read in Web support forums and newsgroups suggest that many administrators and other users have been frustrated in their attempts to get NTBackup to work in their environments.

At my company, we previously used third-party backup software on Windows NT 4.0 because NT 4.0's NTBackup tool wasn't robust enough for our needs. When we upgraded to Windows Server 2003, I took a second look at NTBackup to determine whether the overhauled version would be robust enough and whether it could be easily automated. During this process, I discovered several shortcomings in NTBackup:

  • There's no simple way to write a backup to an arbitrary tape unless you use the /um (unmanaged) option on the command line. This option lets you overwrite an arbitrary tape. However, when NTBackup overwrites a tape in a backup job, it always applies a new media label—either a label you specify or a generic label based on the current date and time. There's no built-in way to tell NTBackup to keep the current label but overwrite the tape.
  • There's no simple way to append backup information to an inserted tape because you must use either the /t (tape name) or /g (globally unique identifier—GUID) options on the command line. Unmanaged mode won't work because you can only append to a specifically designated tape.
  • NTBackup can't eject a tape after a backup.
  • NTBackup can't email or print completed job logs.

To overcome these shortcomings, I created a set of scripts, which Web Table 1 (http://www.windowsitpro.com, InstantDoc ID 44990) lists. The set includes a main script and 13 supporting scripts. The main script, Backup.cmd, uses NTBackup to perform a backup that overwrites the current tape but doesn't change the tape's media label. The 13 supporting scripts perform various functions for Backup.cmd. Together, these scripts provide a backup solution that you can easily customize and use—no script-writing experience is necessary to run them. You simply follow these steps:

  1. Understand what each supporting script does so you can customize a solution.
  2. Understand how the main script works so that you can customize it.
  3. Prepare your environment and the scripts.

Step 1. Understand the Supporting Scripts' Functions
Backup.cmd is the skeleton of this backup solution, whereas the 13 supporting scripts are its muscles. Here's how the 13 scripts flex their muscles and contribute to the end result:

RSMView.cmd. NTBackup manages tapes and other media by using the Removable Storage service, which has a database in the %SystemRoot%\system32\NtmsData directory. You can use a command-line tool called RSM to manage the Removable Storage service. One of RSM's most useful commands is Rsm View, which lets you view the objects in the Removable Storage service's database.

The object types of interest here are the LIBRARY, PHYSICAL_MEDIA, PARTITION, and LOGICAL_MEDIA objects. (The object model for the Removable Storage database contains many other types of objects.) A LIBRARY object represents a physical device that uses removable media. The device we're interested in is the tape drive. One type of object the LIBRARY object can contain is the PHYSICAL_MEDIA object, which represents the physical medium—in this case, a tape. The PHYSICAL_MEDIA object, in turn, can contain a PARTITION object, which represents a partition. (The GUI uses the term side rather than partition, but the two terms refer to the same thing.) One object the PARTITION object can contain is the LOGICAL_MEDIA object, which represents the allocated partition of
a tape.

When you use the Rsm View command to display the objects in a container object (i.e. an object that contains other objects), you must specify the container object by its GUID. Determining the GUID is simply a matter of using one of RSM's options. When you use Rsm View with the /guiddisplay option, RSM outputs a list of objects and their associated GUIDs. With the GUID in hand, you can cut and paste the GUID into the Rsm View command. Cutting and pasting a couple of GUIDs isn't a problem, but having to cut and paste many of them can become quite tedious. Scripting is the perfect solution to eliminate this tedious task. So, the RSMView.cmd script handles the Rsm View command in the rest of the scripts. You don't need to cut and paste a single GUID.

Library.cmd. Library.cmd obtains the tape drive's friendly name and GUID or just the tape drive's GUID. If you run Library.cmd by itself, it will display the tape drive's name and GUID. This information is helpful for troubleshooting if you have problems with the scripts. When Backup.cmd runs Library.cmd, Library.cmd retrieves only the GUID because Backup.cmd doesn't need the tape drive's name.

PhysicalMedia.cmd. PhysicalMedia.cmd obtains the inserted tape's friendly name and physical-media GUID (i.e., the GUID for the physical tape) or just the tape's physical-media GUID. If you run PhysicalMedia.cmd by itself, it will display the tape's name and GUID. When Backup.cmd runs PhysicalMedia.cmd, PhysicalMedia.cmd retrieves only the tape's GUID.

Partition.cmd. Partition.cmd obtains the partition's friendly name and GUID or just the partition's GUID. If you run Partition.cmd by itself, it will display the partition's name and GUID. When Backup.cmd runs Partition.cmd, Partition.cmd returns only the partition's GUID.

MediaGUID.cmd. MediaGUID.cmd outputs the inserted tape's logical-media GUID (i.e., the GUID for the allocated partition of the tape), which is used with NTBackup's /g option. MediaGUID.cmd outputs the GUID in the format that NTBackup needs.

MediaName.cmd. MediaName.cmd obtains the inserted tape's media label as it appears in the Name field on the Side tab of the tape's Properties dialog box in the Removable Storage console. Figure 1 shows a sample Properties dialog box. Backup.cmd uses the media label obtained by MediaName.cmd with NTBackup's /n option to reapply the existing media label when overwriting a tape.

Note that NTBackup uses the Info field when referring to tapes by name. Windows 2003 and Windows XP automatically set the Name field to the Info field. However, when I was testing Win2K, I discovered the Name field was left blank, and I had to copy the label in the Info field to the Name field. In any case, the Name field must match the Info field on the Side tab; otherwise, MediaName.cmd will fail or return incorrect results.

   Previous  [1]  2  3  Next 


Reader Comments
Looks great. Where's the hotlink?

HalJordan January 25, 2005 (Article Rating: )


Like he said. Good article, but where's the scripts? And what the *hell* is up with the BS advertisement links littering your articles?
"You can find the 14 scripts on the Windows IT Pro <link>Web site</link>" - That was really a shameless one!

MightyGorilla January 26, 2005 (Article Rating: )


Same thing, great article, but where is the hot link??????

haber2112 January 26, 2005 (Article Rating: )


Emailed the author, he said he notified the editor...

haber2112 January 26, 2005 (Article Rating: )


The scripts are there; just no link. I found them at http://windowsitpro.com/Files/44990/44990.zip by trial and error. They're nested 3 zipfiles deep, though.

Thrush January 26, 2005 (Article Rating: )


You can find the scripts if you go to the top of the article and click the 44990.zip hotlink under Download the Code. The scripts are in a .zip file that you need to download.

Anonymous User January 31, 2005


Thanks for your comments, and sorry the scripts weren't easier to find. In addition to the link at the top, I've liked the word 'scripts' within the article so other readers can find it more easily.

acarheden January 31, 2005 (Article Rating: )


This was a great article and I had no problem finding the scripts. Thank you.

rayman13 March 30, 2005 (Article Rating: )


everything seems to work great, except that, unless i manually start the Removable Storage mmc snap-in, the media is not detected. I tried setting the Removable Storage service to automatic startup, but it still turns itself off... anyone else have this problem?

acorn June 27, 2005 (Article Rating: )


I got my previous problem solved, still not sure how. I notice in the third page of this article, however, an error:

<snip>
You can use the NTBACKUP_DATAPATH variable as well. For example, if your filename is Weekly full.bks, you'd set the BACKUP variable to

"@%NTBACKUP_DATAPATH%\Weekly full.bks"
</snip>

However, in SetupVars.cmd, the variable is NTBACKUP_DATA, and not NTBACKUP_DATAPATH.

Just letting everyone know about this gotcha. I've worked around this several times, but just noticed today.

Awesome scripts, tho! I'm currently modifying them to backup to file, and still email/print logs.

acorn November 03, 2005 (Article Rating: )


 See More Comments  1   2 

You must log on before posting a comment.

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




Learning Path If you want to find other useful command scripts, check out the Windows Scripting Solutions print newsletter:
"Windows Scripting Solutions"


If you want to learn how to write command scripts, check out:
"“Shell Scripting 101,” Web-exclusive series (Access all 10 articles in this series from this article.)"

"“Getting Started in NT Shell Scripting, Part 1”"

"“Getting Started in NT Shell Scripting, Part 2”"


If you want to run NTBackup from its GUI rather than a script but are having trouble, see:
"“NTBackup Won’t Work?”"


Top Viewed ArticlesView all articles
The Memory-Optimization Hoax

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

Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

Escape From Yesterworld

Kevin points you to the funniest SQL Server website ever! ...


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!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting 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.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Maximize your SharePoint Investment – 8 Cities
Discover best practices and tips for both architecting and administering SharePoint. Early Bird Price of $99 through Sept 15th.

Find a new job now on the all new IT Job Hound!
Search jobs, post your resume, and set up job e-mail alerts!

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Top Tools for Virtualization Disaster Recovery & Replication
View this web seminar on August 14th to learn about two tools that will result in faster backup and restore with P2V disaster recovery.

SharePointConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

VMworld 2008 - Sign Up Today!
Join your peers on September 15-18 at The Venetian Hotel in Las Vegas as VMware hosts VMworld 2008, the leading Virtualization event.



Entrust Unified Communications Certs
Secure Exchange 2007 and save 20%. Now through Sept. 2008.

Increase Application Performance
Free White Paper by Editor's Best winner, Texas Memory Systems.

Need to convert between XML, DBs, EDI, and Excel? Try MapForce free!
Drag & drop to transform between popular data formats – get results instantly or generate code.

Microsoft® Tech•Ed EMEA 2008 IT Professionals
Advance your thinking with new ideas and practical real-world solutions at Microsoft’s FIVE day technical infrastructure conference 3-7 Nov., 2008. Register before 26 September 2008 to save €300.

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Are You Really Compliant with Software Regulations?
View this web seminar that will help you with compliance best practices and check out a management solution to assure that you won’t be in jeopardy of an audit.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 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