To achieve load balancing, we may use multiple Web servers, so we need to configure the same site and application pool for multiple IIS servers. Do we need to re-build one by one? Of course, no, we only need some simple commands to go to iis7 (Windows Server 2008) or iis7.5 (Windows
Server 2008 R2) to export and import these configurations.
When we create a site on iis7 or iis7.5, IIS automatically creates a unique application pool for the site. therefore, to import website information, you must first import the application pool information.
How to export all application pools on iis7 +:
% Windir % \ system32 \ inetsrv \ appcmd list apppool/config/XML> C: \ apppools. xml
This command will export all the application pools on the server, but some of them are unnecessary and need to be deleted. For example:
- Defaultapppool
- Classic. Net apppool
If an application pool with the same name already exists during import, the import will fail.
How to import an application pool:
% Windir % \ system32 \ inetsrv \ appcmd add apppool/in <c: \ apppools. xml
In this way, all application pools can be imported to another server.
How to export all sites:
% Windir % \ system32 \ inetsrv \ appcmd list site/config/XML> C: \ sites. xml
Similarly, we need to edit the sites. xml file to delete unnecessary sites. For example:
How to import sites:
% Windir % \ system32 \ inetsrv \ appcmd add site/in <c: \ sites. xml
Now, the import is complete. Check whether the IIS configurations of the two servers are the same.
In addition, we will introduce how to export and import a site separately.
Export a separate application pool:
% Windir % \ system32 \ inetsrv \ appcmd list apppool "application pool name"
/Config/XML> C: \ myapppool. xml
The name of the application pool to be exported.
Import a separate application pool:
% Windir % \ system32 \ inetsrv \ appcmd add apppool/in <c: \ myapppool. xml
Export a separate site:
% Windir % \ system32 \ inetsrv \ appcmd list site "site name"
/Config/XML> C: \ mywebsite. xml
The site name to be exported in the yellow color font
Import a separate site:
% Windir % \ system32 \ inetsrv \ appcmd add site/in <c: \ mywebsite. xml