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:
- Understand what each supporting script does so you can customize a solution.
- Understand how the main script works so that you can customize it.
- 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.
HalJordan January 25, 2005 (Article Rating: