4

I want to ask you a suggestion about how to proceed in migrating an entire IIS (version 8.5) in Windows Server 2012 R2 to IIS (version 10) on Windows Server 2019. I need a nearly automatic procedure because we have more than 500 sites on that server.

This is the spec for almost each web site:

  1. A folder that contains the entire web site that I can easily replicate on the new server. Each folder has a web.config file that contains a db connection string (I can easily change that using a Python script over all the folders in the root of the web sites directory);

  2. The IIS configuration and web sites that I can easily access through a power shell script like this:

Import-Module Webadministration
$sites = Get-ChildItem -Path IIS:\Sites
foreach($element in $sites){
    $element
}

In which I see all the details of the web site. I know that an export tool exists in IIS, but I don't think it's possible to change the destination folder of the web site and also the bindings to adapt them to the new domain that I need to use on the new server.

At this point I'm a little stuck, because I cannot figure out how to proceed in a smart way. Ideally what I need is, for each web site I export the configuration, to create the web site on the destination IIS, update the reference folder of the web site to the location on the new server along with the binding (I need to change the domain) and start the site (in case of errors, show some sort of warning for manual inspection). Do you have any suggestion on how to proceed and make this process as automatic as possible? Also any scripts for reference will be really appreciated.

1

3 Answers 3

0

If you want to clone all of the IIS websites and configuration from one server to another, you can use msdeploy.exe. On the source server, run the following command as admin to have it copy all of the files and IIS configuration to the destination server, replacing [DestinationServerName] with the name of the server you want to clone to:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:webServer -dest:auto,computerName=[DestinationServerName] -disableSkipDirective:ConfigProtectedData

Note that if you have other IIS websites and configuration setup on the destination server, the above command may wipe it out.

You can also sync individual websites and app pools using the commands:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:apppoolconfig="[APP POOL NAME GOES HERE]" -dest:auto,computerName=[DestinationServerName] -disableSkipDirective:ConfigProtectedData
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:apphostconfig="[WEBSITE NAME GOES HERE]" -dest:auto,computerName=[DestinationServerName] -disableSkipDirective:ConfigProtectedData

See this gist for a bit more info.

Once that is done the destination server should be a mirror of the source server, so if you want anything changed on the destination server (e.g. binding hostnames) you'll still need to do that afterward, either through the IIS GUI, PowerShell, or the C:\Windows\System32\inetsrv\config\ApplicationHost.config file (be sure to back it up before modifying it).

4

Using the WebAdministration module is safe but it's also slow.

As long as your target server is not live yet and you can play around with it, I would directly edit the C:\Windows\System32\inetsrv\config\ApplicationHost.config file.

Copy the <sites> node from the config file on the old server to the config file on the new server.

Also copy any <location ...> notes, usually at the end of the file.

IIS 8.5 and IIS 10 are very similar and this should work. Always make a backup of the file you are changing.

Then you can just use Search and Replace of in the config file to change physical locations or bindings.

-1

Before do the step written by deadlydog, please make sure on the remote computer,the Web Deploy is installed and Web Deployment Agent is started.

Download: https://www.iis.net/downloads/microsoft/web-deploy

Follow all the instructions from this link: https://learn.microsoft.com/en-us/iis/install/installing-publishing-technologies/installing-and-configuring-web-deploy-on-iis-80-or-later

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .