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 


November 13, 2006

A Scripting Solution for Cataloging Your File System

NTCatalog. js catalogs an NTBackup Bks for easy recovery
RSS
View this exclusive article with VIP access -- click here to join |
See More Backup and Recovery Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

Download the Code Here

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.

   Previous  [1]  2  3  Next 


Reader Comments
I didn't find a link for the NTCatalog.js file and the listing says it is an excerpt.

Rob

robcohen November 30, 2006 (Article Rating: )


You must log on before posting a comment.

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




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

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

SET Options and Recompilation

Learn how to tweak your server's SET options so that you don't have to constantly recompile. ...


Related Articles Using Bzip2 Compression with Cmd.exe and PowerShell

Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Management

Virtualization 101

Creating the Business Case for Disaster Recovery Planning and Budgeting

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.


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 Technology Resource 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