The IIS metabase is a data structure for storing IIS configuration settings. In fact, the IIS metabase is a large, hierarchical data structure that supports inheritance. The IIS metabase serves a purpose similar to the Windows 2000 or Windows NT 4.0 Registry, but, unlike the Registry, the IIS metabase requires much less disk space because of its inheritance properties.
Because the IIS metabase contains frequently read and written data, you must back it up. IIS metabases can "break" when you persist bad data to them (it's rare, but accidents happen), and repairing them is difficult. In case you have a disaster that necessitates a restoration, you can use Microsoft Management Console's (MMC's) IIS snap-in in Win2K to restore the IIS metabase.
However, before you can restore an IIS metabase, you must first back it up (I suggest backing it up with the same frequency that you would back up your Microsoft SQL Server databases--maybe even more frequently.) To protect the important metabase data, Microsoft has made backing up the metabase a relatively easy task. Run the IIS snap-in by clicking Start, Programs, Administrative Tools, Internet Services Manager. Right-click the name of your IIS server in MMC, then select Back up/Restore Configuration. Click Create Backup, name your backup, click OK, and you're done. Unless you have an absolutely bloated metabase, the process is complete within seconds.
Restoring the metabase is just as easy. Choose the backup you want to restore, then click Restore. The warning "Restoring is a lengthy operation, which will wipe out all current settings and cause services to be stopped and restarted. Are you sure you want to continue?" appears before restoration begins.
Most IIS administrators want automated maintenance tools. In the IISsamples folder (\inetpub\iissamples\sdk\admin) on your Win2K server, you'll find four Windows Script Host (WSH) scripts that automate backing up and restoring the IIS metabase. Two scripts are for backing up the metabase (one written in VBScript and one written in JScript), and two are for restoring the metabase. These tools demonstrate how you can automate the process, which makes backing up the metabase even easier and more powerful.
The metaback.vbs script takes three parameters:
- The name of the backup
- The version (-v) number of the backup
- A force flag (-f), which forces the overwrite of a backup even if the version exists
Get a command prompt, navigate to the \inetpub\iissamples\sdk\admin folder on your IIS 5.0 server, and type
When the backup is complete, go back to the IIS snap-in, right-click the name of your IIS server in MMC, and select Back up/Restore Configuration. You'll see the backup of the metabase you just made. (It's called myIISmetabaseBak, and the version number will be 0.) If you run the tool again, the utility will automatically increment the backup version to 1, and so on.
Now that you have a WSH script that backs up your IIS metabase automatically, it's simple to add a Win2K scheduled task to enable the script to run automatically at a scheduled time that you define. Open My Computer, then double-click the Scheduled Tasks folder. Double-click Add Scheduled Task to start the Add Scheduled Task Wizard. Click Next to move to the wizard's program selection page. Navigate to the metaback.vbs script and select it. Give the scheduled task a name, such as "Nightly IIS metabase back up." Choose Daily, and click Next. Choose a time that suits your needs. The task needs a security context under which to run, so choose a Win2K domain or local account that has privilege to run WSH scripts. On the last page of the wizard, select the Advanced Properties check box. Click Finish. When the Advanced Properties dialog box appears, click the Task tab, and change the Run: command to the syntax from above. After you click OK, you can right-click the task and select Run to test the task. After running the test, you can check for the next version of the backup you just created in the IIS snap-in.