Setting up a website on IIS is very easy to do. However, it can get very tedious when we have migrate multiple websites from one server to another. For a new server, the easiest to migrate all those settings of course is to clone the server and then we can reconfigure the IP addresses for each web instance from IIS on the new server. But what if that option is not possible?
In this post, we’ll discuss two ways to migrate multiple IIS websites from one server to another. Ideally, this is done to an imaged server that does not have any websites set up yet. Otherwise, more tweaking is needed so we do not override the already existing sites on the new server.
Method 1: Using Shared Configuration in IIS
Please be aware though if you migrate websites from one version of IIS to a newer one, the process can be messy but doable as long as you’re aware of all the gotchas.
Launch IIS Manager and click on the main server node and click on Shared Configuration.
In Shared Configuration screen, click the Export Configuration link.
In the Export Configuration window, enter a Physical Path where you want the configuration files stored. Make sure whichever path you use, it’s an existing folder. Otherwise, you will get an error message that the path does not exist.
Enter a strong Encryption keys password then click OK.
Check your export configuration folder, there should be three files created for you:
Copy all three files to the new server.
Launch IIS Manager on the new server and click on Share Configuration.
This time, check on the Enable shared configuration option and type in all required information to import the configuration from the first server. Click on Apply after you’re done.
That’s it. Again, this is simple to implement if you have a new server, but do not use this method when migrating websites in addition to an already existing website (or websites) on your new server.
Method 2: Using AppCmd.exe
From the Microsoft’s own documentation:
AppCmd.exe is the single command line tool for managing IIS 7 and above. It exposes all key server management functionality through a set of intuitive management objects that can be manipulated from the command line or from scripts.
One of the things you can do with AppCmd is to search, manipulate, export, and import IIS and ASP.NET configuration and configure application pools. So with that, what are the steps to migrate websites to a different server?
From the server where you want to export all the websites, launch Command Prompt and type the following:
C:\> %windir%\System32\inetsrv\appcmd list apppool /config /xml > C:\Temp\AppPools.xml
This command exports all Application Pools in the server, so if you never delete the default ones, you might run into an issue when importing them to the new server. It’s harmless but at some point, you will need to delete them before you can successfully import it.
Once we completed exporting the Application Pools, we still need to export the website settings separately.
Back in Command Prompt, type in the following:
C:\> %windir%\System32\inetsrv\appcmd list site /config /xml > C:\Temp\Websites.xml
Copy the two XML files to the new server. As an example here, the assumption here is the files are copied to the same folder on the new server (C:\Temp).
On the new server, launch Command Prompt and type the following:
C:\> %windir%\System32\inetsrv\appcmd add apppool /in < C:\Temp\AppPools.xml
If successful, you can right away import the websites by typing the following still in the Command Prompt:
C:\> %windir%\System32\inetsrv\appcmd add site /in < C:\Temp\Websites.xml
That’s all there is to it. You might still need to do some adjustments in terms of changing the IP addresses etc. But at least the bulk majority of the settings are already transferred and doing it this way will save you a lot of time instead of doing it one by one.
How do you migrate an IIS 7 site to another server?
Exporting & Importing App Pools and Websites configuration between multiple IIS instances
Getting Started with AppCmd.exe
How to Get Application Pool Identity Password With AppCmd