125

I'm wondering what is the best practice for moving a website to another server (along with all settings, etc.)

  • Manually recreate the site on the new server (not maintainable for obvious reasons)
  • Copy the applicationHost.config settings file
  • Use appcmd to make a backup and restore
  • Use MSDeploy to publish the site on the new machine
  • Use a 3rd party tool

Just wondering what others' experiences have been.

Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
Kalid
  • 22,218
  • 14
  • 44
  • 46
  • Microsoft only recommends Web Deploy (after this tool was created), so before you are reading the answers below, make sure you know for which you are fully at your own risk. – Lex Li Nov 02 '18 at 17:00

7 Answers7

151

I'd say export your server config in IIS manager:

  1. In IIS manager, click the Server node
  2. Go to Shared Configuration under "Management"
  3. Click “Export Configuration”. (You can use a password if you are sending them across the internet, if you are just gonna move them via a USB key then don't sweat it.)
  4. Move these files to your new server

    administration.config
    applicationHost.config
    configEncKey.key 
    
  5. On the new server, go back to the “Shared Configuration” section and check “Enable shared configuration.” Enter the location in physical path to these files and apply them.

  6. It should prompt for the encryption password(if you set it) and reset IIS.

BAM! Go have a beer!

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
chews
  • 2,579
  • 2
  • 20
  • 10
  • 1
    One small tip.... I kept getting Service Unavailable on my second machine. When checking the Event Viewer it talked about a DLL that it couldn't load. This happened because I had different options selected in Windows Setup on the main box. – hacker Apr 04 '09 at 18:56
  • 10
    Probably should use the Import Server or Site Package instead of just copying the files over, although I haven't tested this either. But I do know there are file paths in the applicationHost.config that won't necessarily be present on the new server, which would cause it to break. Also, you should probably mention that there can't be ANY sites currently in IIS, so this process doesn't clobber currently running configuration. – frogstarr78 Jul 07 '11 at 03:28
  • I had an error on first attempt but opened both config files and replaced the name of the machine that they config was exported from to the name of the import machine and it worked. – Brett Bim Jun 24 '13 at 21:00
  • 22
    The last step cannot be overemphasized. Critically important. – Rap Aug 30 '13 at 16:26
  • 10
    Not a great idea if you're migrating to a newer version of IIS. Otherwise, this _is_ the way to do it. – Roy Tinker Dec 23 '15 at 23:31
  • I had an issue when trying to start IIS after following this steps. Just thought of adding a comment with what I did to solve that. I went back to IIS and disabled the Shared Configuration, this will raise a popup allowing you to copy the configuration to the local directory, do that and now restart IIS. It should work. This happened because I used a Shared Drive on the network to export the original config I think... – juanreyesv Jul 29 '16 at 01:31
  • 2
    I am wondering could it work, because it should not: https://learn.microsoft.com/en-us/iis/manage/managing-your-configuration-settings/shared-configuration_264#appendix-3-dealing-with-machine-specific-encrypted-properties – vaso123 Jun 20 '17 at 10:37
  • 4
    IIS Shared Configuration was not designed as a way to migrate settings across machines, so if you hit any issue following this answer, bite yourself and don't blame any others. – Lex Li Nov 02 '18 at 16:52
  • 1
    Awesme... saved my day.. One more thing - need to restart IIS after importing. and it will replace old existing sites in IIS, so keep a backup if needed. – Sachin Feb 13 '19 at 09:29
  • Once the settings are applied to the destination server, then can I turn off the Shared configuration checkbox? – variable Jul 14 '22 at 04:53
  • 1
    Valid for `IIS 8.5 Windows Server 2012 R2 / Windows 8.1` to `IIS 10.0 Windows Server 2016 / Windows 10` ? – Kiquenet Aug 18 '22 at 07:22
  • This bricked my IIS. Thanks a lot. – user169771 Aug 16 '23 at 20:12
31

MSDeploy can migrate all content, config, etc. that is what the IIS team recommends. http://www.iis.net/extensions/WebDeploymentTool

To create a package, run the following command (replace Default Web Site with your web site name):

msdeploy.exe -verb:sync -source:apphostconfig="Default Web Site" -dest:package=c:\dws.zip > DWSpackage7.log

To restore the package, run the following command:

msdeploy.exe -verb:sync -source:package=c:\dws.zip -dest:apphostconfig="Default Web Site" > DWSpackage7.log
sashoalm
  • 75,001
  • 122
  • 434
  • 781
Bill Staples
  • 311
  • 2
  • 2
  • 2
    In 2016 this is still the 'state of the art' but MSDEPLOY 3.6 is truly difficult to work with. I hope they make something new at some point. – Warren P Nov 10 '16 at 15:31
  • 1
    MSDeploy did not transfer sites correctly for us. We ended up with one site containing applications of each of our sites, so the entire structure was wrong. – brianary Dec 05 '17 at 17:32
  • 1
    Surely it is the recommended way, and documentation like https://learn.microsoft.com/en-us/iis/publish/using-web-deploy/synchronize-iis and https://learn.microsoft.com/en-us/iis/publish/using-web-deploy/synchronize-iis-60-web-sites are critial for users to master the necessary steps and key points they need to pay attention to. Most of the issues on the internet are already answered in the articles. If people do spend enough time on such, Web Deploy is not a "difficult" tool to use. – Lex Li Nov 02 '18 at 16:55
22

Here is a helpful website on using appcmd to export/import a site configuration. http://www.microsoftpro.nl/2011/01/27/exporting-and-importing-sites-and-app-pools-from-iis-7-and-7-5/

Roy
  • 221
  • 2
  • 2
  • 1
    Thanks for the link. This also allowed me to modify the site ID and anything else and I didn't have to set up 10 different application and 30 different virtual directories. Big time saver – 2GDave Aug 28 '14 at 19:59
  • 1
    As this approach takes no care of the underlying dependencies (IIS modules and so on), use it at your own risks. – Lex Li Nov 02 '18 at 16:53
  • *Valid for this scenery?*: My websites and, virtualdirs have certificates for https and hostnames. Some websites are public for internet. – Kiquenet Aug 18 '22 at 07:38
15

Microsoft Web Deploy v3 can export and import all your files, the configuration settings, etc. It puts it all into a zip archive ready to import on the new server. It can even upgrade to newer versions of IIS (v7-v8).

http://www.iis.net/extensions/WebDeploymentTool

After installing the tool: Right click your server or website in IIS Management Console, select 'Deploy', 'Export Application...' and run through the export.

On the new server, import the exported zip archive in the same way.

Zymotik
  • 6,412
  • 3
  • 39
  • 48
  • but it takes all files. is there a way to skip taking the files? if you for example migrate an FTP Sever it tries to pick up all files and zip them. – RayofCommand Mar 06 '14 at 11:03
  • 2
    @RayofCommand - When selecting the deployment options, you can clear the "Content" list - then the package doesn't include all the files. – Zhaph - Ben Duguid Mar 14 '14 at 13:20
  • 1
    But only when deploying site-by-site.... not for an entire server move. – Ethan Allen Aug 16 '16 at 01:15
  • 1
    After installing MS Web Deploy on the destination server (IIS8), the IIS Management Console doesn't contain any of the Web Deploy options. – brianary Dec 05 '17 at 22:11
  • @EthanAllen Migration should be carried out at site level if you really want to focus on a real world scenario. A full server migration can leave tons of broken sites, which is not a practical approach to go. – Lex Li Nov 02 '18 at 16:54
  • 1
    I also have no "Deploy" menu after installing the package. –  Sep 26 '19 at 15:47
4

I can't comment up thread due to lack of rep. Another commenter stated they couldn't migrate from a lower version to a higher version of IIS. This is true if you don't merge some files, but if you do you can as I just migrated my IIS 7.5 site to IIS 8.0 using the answer posted by chews.

When the export is created (II7.5), there are two key files (administration.config and applicationHost.config) which have references to resources on the IIS7.5 server. For example, a DLL will be referred with a public key and version specific to 7.5. These are NOT the same on the IIS8 server. The feature configuration may differ as well (I ensured mine were identical). There are some new features in 8 which will never exist in 7.5.

If you are brave enough to merge the two files - it will work. I had to uninstall IIS once because I messed it up, but got it the second time.

I used a merge tool (Beyond Compare) and without something equivalent it would be a huge PITA - but was pretty easy with a good diff tool (five minutes).

To do the merge, the 8.0 files need to be diffed against the exported 7.5 files BEFORE an import is attempted. For the most part, the 8.0 files need to overwrite the server specific stuff in the exported 7.5 files, while leaving the site/app pool specific stuff.

I found that administration.config was almost identical, sans the version info of many entries. This one was easy.

The applicationHost.config has a lot more differences. Some entries are ordered differently, but otherwise identical, so you will have to pick through each difference and figure it out.

I put my 7.5 export files in the System32\inetsrv\config\Export folder prior to merging.

I merged FROM folder System32\inetsrv\config to folder System32\inetsrv\config\Export for both files I mentioned above. I pushed over everything in the FROM files except site specific tags/elements (e.g. applicationPools, customMetadata, sites, authentication). Of special note, there were also many site specific "location" tag blocks that I had to keep, but the new server had its own "location" tag block with server specific defaults that has to be kept.

Lastly, do note that if you use service accounts, these cached passwords are junk and will have to be re-entered for your app pools. None of my sites worked initially, but all that was required was re-entering the passwords for all my app pools and I was up and running.

If someone who can comment mention this post down thread - it will probably help someone else like me who has many sites on one server with complicated configurations.

Regards,

Stuart

Stuart
  • 111
  • 1
  • 8
  • I actually used Stuart's answer for a merged migration, I still don't like MS Web Deploy. – chews Jul 18 '17 at 08:44
3

In my case, the files were already copied, I found the easiest way to follow the steps in this guide: https://www.ryadel.com/en/exporting-importing-app-pools-and-websites-configuration-between-multiple-iis-instances/

I exported AppPools/Websites, copied the xml files to the destination server and Imported AppPools then Websites. Worked very well. This is also another excellent option for this question.

Ralph
  • 1,480
  • 11
  • 16
  • this just gave me errors stating that the default app pool and default web site couldn't be overwritten... no bueno. – devlin carnate Jan 14 '20 at 19:12
  • Try renaming the defaults into something else? and see if they get created with the process explained above? – Ralph Jan 15 '20 at 20:05
  • This worked for me going from IIS7.5 (2008) to IIS10 (2019). Appcmd initially gave me errors on 'Default Web Site' already existing. Renaming didn't work, so I deleted the default website. The import then ran with no errors. – MTAdmin Aug 05 '20 at 16:47
3

use appcmd to export one or all the sites out then reimport into the new server. It could be iis7.0 or 7.5 When you export out using appcmd, the passwords are decrypted, then reimport and they will reencrypt.

Jim
  • 31
  • 1