The Metabase

The metabase is roughly equivalent to the registry for IIS: it holds all the configuration information for IIS. In previous versions, the metabase was a binary file that could be edited only by the metabase editor, part of the resource kit. In IIS 6, the metabase is a good old XML text file (as shown in Figure 1-4) that can be edited with Notepad. Even though the metabase in IIS 6 is completely different, it is still completely compatible with the IIS 5 metabase, so all the same APIs and scripts still work.

click to expand
Figure 1-4: View of a metabase file

The metabase is stored in %systemroot%\system32\inetsrv and is called, appropriately enough, MetaBase.xml. The schema for the metabase is called MBSchema.xml. Because the metabase is a text file, it can easily be edited with any text editor, and it is less likely to be corrupted. Even if the metabase does experience corruption, it can easily be fixed or recovered.

Metabase History

The metabase is backed up and “versioned” periodically by IIS. Two version numbers are used for the metabase: a major version number and a minor version number. The name of the backup files are MetaBase_[10 digit major version number]_[10 digit minor version number].xml and MBSchema_[10 digit major version number]_[10 digit minor version number].xml (for example, MBSchema_0000000160_0000000000.xml).

By default, ten copies of the metabase files are stored. This allows the metabase to be rolled back to any of these previous versions. The number of metabase versions kept is configurable by editing the MaxHistoryFiles property in the metabase. As a general rule, you shouldn’t configure less that ten copies of the metabase history to be kept. Each time the metabase is saved, a backup copy of the metabase and corresponding schema are made in the history folder. IIS checks to see how many history file pairs are present, and if more files are present than the value of MaxHistoryFiles, IIS deletes the oldest pair.

History Folder Location

By default, the history folder is located at %systemroot%\system32\inetsrv\history. This is configurable by changing the registry key under HKEY_LOCAL_MACHINE\Software\ Microsoft\InetMGR\Parameters\. Add a new string value named MetadataFile. The value of the MetadataFile key should be the absolute pathname of the location to which you want to store the metabase files (for example: D:\IISMetadata\ThisIsMyMetabase.xml).

Caution 

As always, editing the registry is a dangerous thing, and the usual warnings apply. Be very, very careful.

When you change the location of the metabase files, make sure all the metabase files are moved to the new location, or else when IIS starts up, it will create the default metabase in the new location. The changes to the metabase location will not take effect until the IIS Admin and World Wide Web Publishing service are restarted.

Backing Up and Restoring the Metabase

While you can use history files to restore metabase configuration files, performing a backup of the metabase has some advantages. For one, metabase history files can be used only on the computer on which they were created, while backups can be restored to another computer. The metabase can be backed up on demand through the IIS MMC.

The metabase can be fully backed up and restored using the Backup/Restore Configuration option in the IIS MMC. To access it, highlight the computer in IIS, and choose Action | All Tasks | Backup/Restore Configuration.

From the Configuration Backup/Restore dialog box shown in Figure 1-5, you can choose to back up, restore, or delete a metabase backup. All the metabase backups appear here.

click to expand
Figure 1-5: Backup/restore configuration

The Backup Option

When you create a backup, you must specify a backup name. The backup file is located in %systemroot%\System32\Inetsrv\MetaBack. The metabase has a .MD0 extension, and the schema has a .SC0 extension. Each backup with the same name will increment the number in the extension to preserve the previous backup. The password option encrypts the backup with the password you specify. It can be decrypted only with the same password. This allows a web site to be moved from one computer to another, while keeping the metabase secure.

Caution 

Moving the metabase to another computer works well only if the drive configuration is the same on the new computer. Because pathnames are stored in the metabase, if your content is on a different drive, the web site won’t work properly. Extra care must also be taken if the site has an SSL certificate.

The Restore Option

To restore a configuration, choose that configuration, and then click the Restore button. When you click Restore, a warning will pop up, informing you that all your settings will be wiped out (they’ll be restored to the saved configuration) and that all the services will be stopped and restarted. This action is not to be undertaken on a whim.

The Delete Option

To delete a metabase backup, choose the backup and click Delete. You will be asked if you are sure you want to delete, and if you say Yes, the backup is deleted.

Metabase Snapshots

Another way to back up the metabase is to use Windows Backup Utility. The Backup Utility uses the Metabase Snapshot Writer automatically to make sure the MetaBase.xml and MBSchema.xml files are successfully backed up.When the Backup Utility detects that the drive to be backed up contains the metabase, it writes the in-memory metabase to the files and prevents anything from being added to the in-memory metabase for up to two minutes.

Tip 

The Metabase Snapshot Writer is not used during Backup Utility restores. If you are going to restore the metabase files, make sure that you stop the IIS services first, so you don’t risk data loss.

Editing the Metabase

When the Enable Direct Metabase Edit option is enabled in the Properties window (see Figure 1-3), you can use a few different methods to modify the metabase while IIS is running.

Notepad or Text Editor

A favorite for those of you who like doing things by hand, a text editor can be used to edit the metabase directly. Just open the MetaBase.xml file, make the changes, and save. They’ll take effect immediately.

IIS WMI Provider

Microsoft has a new push for all its programs to be accessible to Windows Management Instrumentation (WMI). So you should be able to use WMI to access the same configuration items you could through the user interface. WMI edits the saved copy of the metabase on the disk.

IIS ADSI Provider

ADSI, the Active Directory Scripting Interface, edits the copy of the metabase in memory. ADSI creates an instance of the metabase object that you can manipulate programmatically.

Editing the metabase is explained in further detail and some examples are given in Chapter 9.

The Metabase Schema

The metabase schema is loaded into memory with the metabase when IIS initializes. It contains the definitions for all the properties that can be written to the keys in the metabase. The schema also enforces these definitions to a certain extent. As long as a property is written as an in-schema property, it works because it has been defined. This can be overridden by using a custom property in the MetaBase.xml file, which is essentially creating your own definition for a property. The goal here is to define all the properties used, rather than limiting you to a certain few variables. While editing the metabase isn’t difficult, editing the metabase schema isn’t recommended.




IIS 6(c) The Complete Reference
IIS 6: The Complete Reference
ISBN: 0072224959
EAN: 2147483647
Year: 2005
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net