Recently, I was invited to give a presentation at the Orlando DotNetNuke Usersgroup around DotNetNuke website performance. The first tidbit of information I provided was that when you’re running on a Windows Cloud Server or Windows VPS Server or a Managed Windows Server, you always to make backups of your configuration before making sweeping changes. The quickest way to backup the IIS Metabase is via command line:
Backing up the IIS Configuration via Command Line:
%windir%\system32\inetsrv\appcmd.exe add backup “RUTROH”
This runs the appcmd command that allows you completely manage the IIS configuration from commandline. and create a new backup called “RutRoh” (Just like scooby doo and when you need this backup the first thing you’re going to say is .. RUT ROH!
Restoring the IIS Configuration via Command Line:
Assuming your backup is named RUTROH you’ll execute the following:
%windir%\system32\inetsrv\appcmd.exe restore backup “RUTROH”
What if you don’t know which backup you want to restore? Then you can list your backups with the command:
%windir%\system32\inetsrv\appcmd.exe list backup
and then restore the appropriate backup.
What if I didn’t make a backup of my IIS Configuration? Am I stuck?
The good news is that in Windows Server 2008 and above IIS has a configuration history and automatically checks for configuration changes every 2 minutes and stores the last 10 backups for you AUTOMATICALLY in the c:\inetpub\history folder so there’s a good chance you have a backup already anyway. To restore one of those backups you just copy the applicationhost.config file from one of the backups over the top of your existing applicationhost.config file (I always make a copy of the current applicationhost.config file before replacing it, just in case!)
If you want to learn more about this feature and even how to increase the number of histories/backups it keeps visit: http://learn.iis.net/page.aspx/129/using-iis-configuration-history
Now it’s your turn
So there you have, a quick 2 minute introduction on how to backup and restore your IIS configuration quickly and how to restore your IIS configuration even if you didn’t make a backup yourself (because IIS did it for you). If this blog article helped you, I’d love it if you left a comment and even tweeted the article.