Migrating sites from IIS7 to IIS8
Posted 15 May 2014
I was recently tasked with migrating a bunch of sites from a Windows 2008 server to a Windows 2012 server. I expected this to be a well know path but it’s not. I tried to use WebDeploy, it’s a complete disaster.
I ended up cherry-picking IIS configuration backups in a merge tool. Not pretty but it worked like a charm.
What’s wrong with WebDeploy
WebDeploy is mostly an automation tool for deploying websites. It assumes a bunch of things. For example that you already created the site and the apppool. I am not looking to do that by hand 20 times or so.
It also seems to be incapable of creating virtual directories etc. In effect, a deployment package for a site seems to contain only files, none of the IIS structural configuration that’s so tedious to setup by hand.
Looking for ways to migrate the IIS configuration itself I found that WebDeploy supports server level packages too. This seems to create a package with all sites and a whole slew of configuration data. Great, or so I thought.
When I tried to deploy that on the server I found that IIS would no longer work. At all.
WebDeploy had messed up the .NET Framework configuration files, machine wide!
The alternative
I was not looking forward to manually configuring 15 sites with their app pools, virtual directories and all that. The chances of me messing that up in multiple places are 100%.
So I started looking into IIS’ built-in backup functionality:
%windir%\system32\inetsrv\appcmd add backup "migration"
This creates a backup of the IIS configuration in
%windir%\system32\inetsrv\backup\migration
The backup consists of XML files and being a developer, I know how to deal with XML.
Next step is to create a backup on the destination server. I named that ‘Pre-Migration’ and copied it to ‘Migration’ so I would have a version to return to.
The file that has the actual site configurations is applicationHost.config, and is mostly compatible between IIS7 and IIS8. The XML is pretty straight forward and I was able to merge the bits I wanted into the backup file on the new server.
The relevant sections are:
- applicationPools
- sites
- locations
Now restore the backup:
%windir%\system32\inetsrv\appcmd restore backup "migration"
Marnix
Oops, good point. I've updated the post.
Reuben
Is that command to restore the back correct?
It looks suspiciously like the command to make the backup.