When using multiple IIS server in a Load Balanced Environment it will be alot of work to create all your website twice with the same settings on each webserver. Therefor it is possible to export and import your configuration from one IIS webserver to the other.
When you create a website in IIS a unique application pool will also be created and used by this website, that’s why you need to import these application pools first on the second webserver before importing the website(s).
Export all Application Pools from IIS
1 |
%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml |
This command will export all IIS application pools to xml file.
Therefore you need to edit the apppools.xml and remove the application that you do not need to import for example:
- DefaultAppPool
- Classic .NET AppPool
- SecurityTokenServiceApplicationPool
And other apppools that already exist on the second webserver, appcmd doesn’t skip already existing apppools, it just quit’s and doesn’t import any.
Import all Application Pools to IIS
1 |
%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml |
All the AppPools in the xml will be created on your second webserver.
Export all IIS websites
1 |
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml |
This command will export all IIS websites to xml file, therefor you need to edit the sites.xml and remove the websites that you do not need to import for example “Default Website”
And all other websites that already exist on the second webserver.
Import all websites to IIS
1 |
%windir%\system32\inetsrv\appcmd add site /in < c:\sites.xml |
It’s also possible to export a single website or application pool . All you need to do is add the name of the Application Pool or Website to the command line:
Export a single application pool from IIS
1 |
%windir%\system32\inetsrv\appcmd list apppool “MyAppPool” /config /xml > c:\myapppool.xml |
Import a single application pool to IIS
1 |
%windir%\system32\inetsrv\appcmd add apppool /in < c:\myapppool.xml |
Export a single website from IIS
1 |
%windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml |
Import a single website to IIS
1 |
%windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml |
Good luck!