Recipe12.17.Exporting and Importing the Metabase


Recipe 12.17. Exporting and Importing the Metabase

Problem

You want to export or import a portion of the metabase. This can be useful when you want to clone the configuration of a web site or virtual directory by copying it to another IIS computer.

Solution

Using a graphical user interface

You can export the metabase configuration for an individual web site, all web sites, an individual FTP site, all FTP sites, an individual virtual directory, a file, an individual application pool, or all application pools as follows:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, right-click on the node whose metabase configuration you want to export and select All Tasks Save Configuration to a File.

  3. Type a name for the exported file and, if desired, browse to a different directory where you want to save the file.

  4. Optionally password protect the export file by typing a password and confirming it.

  5. Click OK.

For example, to export the portion of the metabase that contains configuration settings for a web site named My Web Site, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, right-click on My Web Site and select All Tasks To import the previously saved configuration for My Web Site back into the Metabase, do the following:

    1. Open Internet Information Services (IIS) Manager.

    2. In the left pane, right-click on Web Sites and select New

      Type the path to the saved configuration file or click Browse to select it.

    3. Click the Read File button to display a list of web sites contained in the saved configuration file.

    4. Select the web site named My Web Site and click OK.

    5. Specify a password if prompted and click OK.

    6. Right-click on the web site and select Start to start it.

    You can similarly import the configuration for an FTP site, virtual directory, or application pool.

    Using a command-line interface

    The following command exports the configuration of the Default Web Site to a configuration file named default.xml:

    > iiscnfg /export /f default.xml /sp /lm/w3svc/1 /children

    Here /sp specifies the source path, i.e., the metabase key, you want to export. In this case, I used /lm/w3svc/1, which represents the Default Web Site (site ID = 1 under the W3SVC service). The /children option recursively exports subkeys (child keys) as well.

    This command exports the configuration of a site with ID number 66485902 and password protects the export file so you can import it onto a different IIS computer:

    > iiscnfg /export /f anothersite.xml /sp /lm/w3svc/66485902 /children /p <password>

    If you leave out the /children option, only the configuration of the virtual root will be exported, and not the configuration of any virtual directories below the root.

    Let's now import the configuration of the Default Web Site, which we exported above as default.xml, but first let's delete the Default Web Site:

    > iisweb /delete "Default Web Site"

    To recreate the Default Web Site, import its previously saved configuration:

    > iiscnfg /import /f default.xml /sp /lm/w3svc/1 /dp /lm/w3svc/1 /children

    Here /dp stands for the destination path, i.e., the metabase key, into which you want to import the configuration data. Again, /children ensures that subkeys are imported as well.

    We can even import a second copy of the Default Web Site and assign it the site ID number 2 as follows:

    > iiscnfg /import /f default.xml /sp /lm/w3svc/1 /dp /lm/w3svc/2 /children

    Note that in IIS Manager, the copy of the site won't start unless you assign it a unique IP address.

    Discussion

    Metabase export files don't include encrypted properties (such as AdminACL) the way metabase backup files do. If you want to export a configuration that can be imported into a different IIS computer, be sure to password protect the export file and remove any computer-specific information it contains such as metabase properties referencing the IUSR or IWAM accounts used by IIS, the AdminACL, and any properties that use passwords before exporting it. Also, be sure to recreate the content folders on the target computer exactly as on the source computer.



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

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