The first thing you should do after setting up an IIS7-server

As you’re probably well aware IIS7 relies heavily on a master configuration file named ApplicationHost.config. Now, instead of using a history file like IIS6 did, IIS7 will check this file every 2 minutes to see if it’s changed. If the file has been updated, then a backup copy of the old .config will be stored in the inetpub\history-directory.

Configuration history

This is really cool and a very useful feature. There’s only one little caveat in my opinion and that’s the fact that by default IIS7 will only save up to 10 backups. All the other backups will be discarded. This means that if you’re spending 20 minutes fiddling with the settings in ApplicationHost.config you will quite likely have overwritten all your old backups. Now, if something goes wrong at that point and you decide to spend another 20 minutes trying to fix this problem by further editing the ApplicationHost.config you will surely have overwritten the backups.

In a worst case scenario you might even have gone from Healthy Server to Unstable Server to Server Down and you now find that you aren’t even able to restore it to the Unstable state.

My suggestion is to increase the default number of backups to 100, or why not 1000? You can then feel certain that any backups taken aren’t overwritten when you try to undo the very same changes. Here’s how you do it:

  1. Go to %windir%\system32\inetsrv\config\
  2. Open applicationHost.config in notepad
  3. Locate the system.applicationHost section group
  4. Add the following item to the section group:
    <configHistory maxHistories=”100″ period=”00:02:00″ />
    (Naturally the maxHistories value can be whichever value you prefer)
  5. Save

To restore one of the previous configurations, simply go to inetpub\history\cfgHistory_[nnnnnnnnnn] and copy the config from there, or use appcmd. (See below)

Backup using appcmd

Now that we’ve done this there is one more thing I’d strongly recommend doing:

  1. Open up a command-line with administrative priviliges
  2. Go to %windir%\system32\inetsrv
  3. Run “appcmd add backup “[Name of your backup]”

What you’ve done now is to create a manual backup of your current config. It’s always good to have a decent (and persistent) restore point to return to.

If you wish to restore this backup you simply use the following syntax: “appcmd restore backup “[Name of your backup]”“. You can also delete a backup using the “delete” keyword, or you can list all backups, including the ones generated by the Configuration history, like this: “appcmd list backup

Okay, so now we have made sure we have some extensive automatic backups in place which might save us a lot of headaches later on.


Later! / Johan

Comments (1)

  1. Mark Sowul says:

    If you’re using IIS7, that means you’re on Vista Business or better, or WS 2008 – so don’t forget the "Restore Previous Versions" feature which can also save your hide.