Little back I wrote a sweet little IIS7 UI module for taking backup and restore of IIS configuration. At that time I didn’t add the shared host configuration since it was in its early stage, and to be honest I didn’t think about it when wrote that module. Below is the sample code which would give you the path of the IIS configuration. You got to read the path from the Redirection.config. It is stored in the configurationRedirection as “path” attribute; when this is null, then IIS takes the configuration store from %Windir%\system32\inetsrv\config path.

ServerManager sm = new ServerManager();
Configuration c = sm.GetRedirectionConfiguration();
this.InetsrvPath = Environment.GetEnvironmentVariable("windir") + @"\system32\inetsrv";
this.configPath = c.GetSection("configurationRedirection").Attributes["path"].Value.ToString();
if (configPath.CompareTo("") == 0)
       configPath = InetsrvPath;</PRE< P>

 

You can just do this backup and restore by appcmd itself, below are the commands:

appcmd add backup "backupname"

appcmd restore backup "backupname"

Here is my updated module, and I’ve not changed any UI for this except adding the shared host functionality. This is how it looks:

image

In the available Backups drop combo box, you will find all the available backups. Select the one which you want to restore and click "Restore" button. It would look like below:

image

Here is the link for the DLL:

 

And, here is the source:

  To add this module in your IIS 7 manager follow the below steps:

  1. Download the IIS7BackupRestore.dll.
  2. From inetsrv folder Drag and Drop the IIS7BackupRestore.dll into the Global Assembly Cache (C:\Windows\assembly) or use GacUtil -i IIS7BackupRestore.dll to install it to the GAC.
  3. Under File Menu, browse for the file %WinDir%\System32\InetSrv\config\Administration.config.
  4. Search for the <moduleProviders> section and add the following

    <add name="IIS7BackupRestoreUI" type="IIS7BackupRestoreUI.MyModuleProvider, IIS7BackupRestoreUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=db9daa3d2ea5f6fd" />

  5. Search for the <modules> section and add the following

    <add name="IIS7BackupRestoreUI" />

  6. Open Inetmgr and You will see the module listed in your IIS 7 Manager if you would’ve followed the above steps properly.

Let me know if this helps you!