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:
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:
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:
- Download the IIS7BackupRestore.dll.
- 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.
- Under File Menu, browse for the file %WinDir%\System32\InetSrv\config\Administration.config.
- Search for the <moduleProviders> section and add the following
<add name="IIS7BackupRestoreUI" type="IIS7BackupRestoreUI.MyModuleProvider, IIS7BackupRestoreUI, Version=22.214.171.124, Culture=neutral, PublicKeyToken=db9daa3d2ea5f6fd" />
- Search for the <modules> section and add the following
<add name="IIS7BackupRestoreUI" />
- 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!