In "Gathering File System Data" (November 2006, InstantDoc ID 93451), I presented aWindows Script Components (WSC) object, FileDB .wsc, that saves information about files to a comma-separated values (CSV) text file. I created the component after a user accidentally deleted a file on the server. A catalog-searching tool would have been extremely helpful in finding the file on the backup tape, but I was forced to browse manually through thousands of files and folders because NTBackup doesn't provide a way to search a backup catalog.
To save time in the future, I decided to write a script that could use the
FileSystemObject object to iterate through one or more folders, build a list
of files, and save the list to a CSV file. This month, I present NTCatalog.js,
which uses the FileDB.wsc component to catalog an NTBackup .bks file's information
to a CSV file.
Backup Selection Files
When you schedule an NTBackup job, the backup utility creates a Unicode text
file that has a .bks extension and contains the names of files and folders to
include in (or exclude from) the backup. You can also create a .bks file manually
by selecting files and folders in the NTBackup window and choosing the Save
Selections option from the Job menu.
Each line of a .bks file starts with either a filename or a folder name. (This
rule has two exceptions, which I'll explain in a moment.) If the file or folder
is to be excluded from the backup, the line ends with the string /Exclude. When
the line contains a filename, NTBackup backs up that specific file. (NTBackup
doesn't support wildcard backups, such as C:\Folder\*.doc.) When the line contains
a folder name, NTBackup backs up all files in that folder. In both cases, NTBackup
backs up files in subfolders as well. For example, if your .bks file contains
the line C:\Docs\file.doc, NTBackup will back up C:\Docs\File.doc, but also
all other files named file.doc that exist in subfolders of C:\Docs.
Figure 1 shows a sample .bks file. To allow
NTBackup to differentiate between folders and files, folder names must be followed
by a backslash (\). When a name isn't followed by a backslash, NTBackup treats
the name as a filename.
If NTBackup were using this sample file, the utility would back up everything
on the C drive and everything in the Shares folder on the D drive. The utility
wouldn't back up the Videos folder in the Shares folder, nor the subfolders
under Videos. But it would back up a file named CompanyIntro.mpg in the Videos
folder and in all subfolders of the Videos folder.
As I stated earlier, there are two exceptions to the rule that each line in a .bks file must contain a folder name or a filename. First, if the string SystemState appears on the last line, NTBackup backs up the system state. Second, a .bks file can also specify that Exchange Server be backed up. In this case, the syntax depends on the version of Exchange. For example, for Exchange Server 2003, the syntax looks like this:
JET servername\Microsoft
Information Store\First
Storage Group\
where servername is the name of the Exchange server.
The .bks Unicode File Format
You need to know one more thing about working with .bks files. As I've said,
a .bks file is Unicode text.
However, you can't save .bks files properly with Notepad because Notepad prefixes
Unicode text files with a byte-order marker, which NTBackup doesn't understand.
The following workaround can help. To create your own .bks file, create it as ANSI or ASCII text instead of Unicode. After saving the file, use cmd.exe's /u option to type the filename and redirect the file to a Unicode text file. For example, to save the file selections.txt to selections.bks, type the following command all on one line at a command prompt:
cmd /u /c
type selections.txt >
selections.bks
The /u option tells cmd.exe that the output from its internal commands should
be Unicode. The /c option executes the remainder of the line as a command. The
Type command sends the selections.txt file to standard output, which is then
redirected to the selections.bks file. Because Type is an internal command,
the selections.bks file will be in Unicode format. Cmd.exe doesn't create a
byte-order marker at the beginning of Unicode files, so you can use cmd.exe
with the /u option to convert a plaintext file containing backup selections
to a valid .bks file.
Rob
robcohen November 30, 2006 (Article Rating: