Setting up a website on IIS is very easy to do. However, it can get very tedious when we have to migrate multiple IIS websites to a new server. For a really brand 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
This method is the simplest to implement, but only use this if you have a brand new server. DO NOT use this method when migrating websites in addition to an already existing website (or websites) on the destination server.
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:
- administration.config
- applicationHost.config
- configEncKey.key
-
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.
-
Optional: Typically you don’t need to user User name and Password, unless if you need your credential to access the Physical path where you store the export files. In this case, you can type in your user name (NTID or a service account) and password.
-
After clicking Apply link from either step 7 or step 8 (not both), you will be asked to enter your Encryption Keys Password you entered from step 3.
-
If you entered the correct Encryption Keys Password, you’ll see a notice such as this:
Your existing IIS encryption keys will be backed up in the current configuration directory on your local computer. To restore these keys at a later time, turn off shared configuration.
Just click the OK button.
-
Finally, you’ll see a succesful message below:
The changes have been successfully saved. You must close and reopen IIS Manager for it to recognize the configuration changes that you have made.
Just click OK button again.
-
Close and reopen IIS Manager to see the changes take effect.
That’s it.
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.
Further Reading
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
Tayo says
Hello, thank you for your teaching. How about moving a specific application on IIS server to an App service instance or Azure VM
Milo says
The last sentence of method 1 should be at the beginning. As it is, the meaning for me was: ‘Now that you have completed all these steps, you will see that all of your existing websites have disappeared and you will have to start over’.
platt says
Totally makes sense, I should have given the disclaimer in the beginning of the instruction. Thanks for your feedback.
IT Joe says
Using the shared configuration you don’t state what username to use. No username is given when we export the config and it’s not detailed here where that is derived from.
platt says
Thanks for your feedback, I added the steps above to be more clear. Just to reiterate, typically it would work without the need any username and password.