Customizing SetupVars.cmd. Open SetupVars.cmd, which Listing 2 shows, in Notepad or another text editor. In the code at callout A in Listing 2, you need to define at least the RSM_LIBRARY and RSM_REFRESH variables. If you plan to use TapePrep.cmd, you must also define the RSM_POOL variable.
RSM_LIBRARY defines the friendly name for your tape drive. If you're unsure of this name, you can open a command-shell window and run the command
RSMView library
to obtain the list of libraries on your system. Then simply copy the friendly name (but not the GUID) into SetupVars.cmd. You don't need to enclose the library's friendly name in quotes if it contains spaces. To check whether you have specified the library name correctly, type the following command at a command prompt
Library
You should see the library's friendly name followed by its GUID. You must make sure that the library's friendly name doesn't contain any of the following reserved shell characters:
( ) < > ^ & |
If your library's friendly name contains any of these characters, you need to remove them from the library's name. To do so, first open the Removable Storage console by selecting Start, Run, ntmsmgr.msc, OK. In the left pane, expand Libraries (in Windows 2003 and XP) or Physical Locations (in Win2K). Right-click the tape drive in the left pane and choose Properties. Remove any of the offending characters from the Name text box, and click OK.
You need to set RSM_REFRESH to the number of seconds that Refresh.cmd should pause after performing a device refresh. This value depends on your hardware; set it to the number of seconds it takes to insert and remove a tape. A good starting point is 30 seconds.
If you plan to use TapePrep.cmd, set RSM_POOL to the media pool that matches the type of media used by your tape drive. For example, if your tape drive uses Travan tapes, specify the Travan media pool:
Set RSM_POOL=Travan
If the value contains spaces (e.g., 4mm DDS), you don't need to enclose it in quotes.
The code at callout B in Listing 2 defines the post-backup behavior. Setting the EJECT variable to YES prompts Eject.cmd to eject the tape. Setting MAILLOG to YES causes MailLog.cmd to email the NTBackup log file to the specified recipient. Setting PRINTLOG to YES prompts PrintLog.cmd to print the NTBackup log file on the default printer.
If you set MAILLOG to YES, you need to set the variables in the code at callout C in Listing 2. (If you set MAILLOG to NO, you don't need to do anything with this code.) Set the SMTPSERVER variable to the DNS name or IP address of an SMTP server on your network. (In this example, no authentication is used. However, blat.exe supports SMTP authentication. For information about how to incorporate authentication, see the blat.exe documentation.) Set SENDER to the email address you want to appear in the message's From field. Set RECIPIENTS to the email address of the person you want to receive the message. You can specify more than one recipient. Simply separate the addresses with a comma; no spaces are allowed.
You don't need to do anything with the remaining code, which defines the DTSTAMP variable, ERR constants, and NTBACKUP_DATAPATH variable. Backup.cmd uses DTSTAMP to create a date and time stamp. The ERR constants define the exit codes for the scripts. And the NTBACKUP_DATAPATH variable points to NTBackup's data folder, which stores the backup selection (.bks) files and log files.
Customizing Backup.cmd. Open Backup.cmd in Notepad or another text editor. In the code at callout A in Listing 1, set the BACKUP variable to the directory or directories you want to back up. Separate directory names with spaces. If a directory contains spaces, enclose it in quotes. Alternatively, you can specify a .bks file. Enter the full pathname to the file, prefix it with the @ symbol, and enclose it in quotes if it contains spaces. 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"
Set the JOBNAME variable, which is used with NTBackup's /j option, to the backup job's name. This name will appear in NTBackup's Backup Reports window. Set SETDESC, which is used with NTBackup's /d option, to the backup job's description. This description will appear in the log file and in the Description column on the Restore tab in NTBackup's UI. The optional DTSTAMP variable that appears at the end of the description will let you see at a glance when the backup job ran.
You can customize the JOBINFO variable, but it's not required. This variable specifies the text used in error messages and in the email subject line. Note that it references the JOBNAME and COMPUTERNAME variables so you'll know at a glance the job and computer that generated the message.
You use the OPTIONS variable to define NTBackup's command-line options. For example, suppose you want NTBackup to append the backup to whatever tape happens to be inserted. You simply add the /a option to the OPTIONS variable. (You also need to remove /n "%MEDIANAME%" in the Set COMMAND= line because you can't use /n with /a.)
You can specify any of NTBackup's command-line options, except /j, /d, /n, /g, /f, /t, /p, and /um. As I mentioned previously, /j and /d are already defined in JOBNAME and SETDESC, respectively. The script automatically determines the tape's media label (/n) and GUID (/g). The other options (/f, /t, /p, and /um) shouldn't be used because they create conflicts.
The LOGFILE variable exists for troubleshooting purposes. Each script's output is redirected to this file, along with the tape's name and logical-media GUID, the NTBackup command line, and that command's exit code. If you leave the LOGFILE variable set to %~dpn0.log, the file will be created in the same directory as Backup.cmd and will have the filename Backup.log.
Ready, Test, Go
After you've completed these three steps, the backup scripts are ready to test in a nonproduction environment. Even though I tested them with Windows 2003, XP, and Win2K, you should always test any new scripts in a controlled lab environment before deploying them. After you've successfully tested them, you'll have a flexible backup solution to use.
End of Article
HalJordan January 25, 2005 (Article Rating: