While using multiple IIS server in a Load Balanced Environment, it will be a lot of work to create all your website twice with the same settings on each webserver. In this scenario, it will be create more critical to create large number of binding for each server, so there is possible to export and import your configuration from one webserver to the other by using command.
Executed and Tested Version
OS : Windows 10
IIS : 10.0.15063.0
To Export the website/IIS Bindings:
Macking backup of IIS configuration is as simple as copying the directory into a backup directory, so you don’t need anything special to do it. Just execute the below command in Command prompt to make the backup copy in “C” drive with file name as Import_ProdBindings.xml
%windir%\system32\inetsrv\appcmd list site /config /xml > C:\Import_ProdBindings.xml
To Import the website/IIS Bindings:
As like Backup, it very simple to add the config to the IIS by using below command.
%windir%\system32\inetsrv\appcmd add site /in < C:\Import_ProdBindings.xml
I had faced the below error while exporting the config to the IIS. This error is due to the presence of “Default Web Site” in targeted IIS. So you can deleted the exitsting one before executing the new config OR you can change the name of “Default Web Site” in config and start the import from backup.
Pretty easy, eh? Except for the dirty little secret everyone knows…remembering to do a backup before starting the Import!
“ERROR ( message:Failed to add duplicate collection element “Default Web Site”. )”