In this post I thought I’d shed some light on the IIS Configuration History feature built into IIS7 onwards – it’s a great feature that many developers don’t know about.

IIS Logo

Houston, We Have A Problem …

We’ve all been there at one point or another … a change was made to the IIS web server configuration at some point in time and it’s broken your site … you need to undo it … if you only you could go back in time to see your old configuration.

What should you do? Blame it on someone else? Quietly book an extended vacation ….

No need to worry. From IIS 7 onwards your IIS configuration will be automatically backed up and can easily be restored to an earlier point in time.

How Does It Work?

The “Application Host Help Service” Windows Service periodically checks your IIS configuration, if it notices any changes it’ll back them up to default directory %SystemDrive%\inetpub\history.

By default, the service will scan your IIS configuration every 2 minutes. If the service is stopped then the IIS configuration history feature will not work.

To recover your configuration from a backup, copy the folder contents to the main IIS working directory %Windir%\system32\inetsrv\config.

More information can be found here.

Windows Explorer Screenshot
Windows Explorer Screenshot

Configuration

You can set the maximum number of versions to retain in configuration file %windir%\system32\inetsrv\config\applicationHost.config. By default, it’s configured to keep a maximum of 10 previous versions. I’d recommend that you increase this setting to give yourself added piece of mind – perhaps to around “30”.

There isn’t any harm in doing so.

<configHistory maxHistories="15" />

We can also configure the amount of time (in seconds) the service waits between re-scanning the configuration files by specifying the period attribute.

<configHistory maxHistories="15" period="00:00:10" />

You can find more information regarding configuration here.

Restoring a Backup

You can restore a previous backup via the command prompt:

cd %windir%\system32\inetsrv 
appcmd list backups 
appcmd restore backup <BACKUP NAME>
Restore IIS Configuration

It Ain’t Working!

If for some reason your IIS configuration isn’t being backed up and you’ve verified that the Windows Service is running, check the Event Viewer for any errors thrown by “IIS-AppHstSvc”.

Event Viewer Errors
Shane Bartholomeusz
Latest posts by Shane Bartholomeusz (see all)