129

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.

1
  • 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
    Commented Nov 2, 2018 at 17:00

7 Answers 7

158

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!

12
  • 12
    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. Commented Jul 7, 2011 at 3:28
  • 25
    The last step cannot be overemphasized. Critically important.
    – Rap
    Commented Aug 30, 2013 at 16:26
  • 11
    Not a great idea if you're migrating to a newer version of IIS. Otherwise, this is the way to do it.
    – Roy Tinker
    Commented Dec 23, 2015 at 23:31
  • 2
    I am wondering could it work, because it should not: learn.microsoft.com/en-us/iis/manage/…
    – vaso123
    Commented Jun 20, 2017 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
    Commented Nov 2, 2018 at 16:52
33

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
3
  • 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
    Commented Nov 10, 2016 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
    Commented Dec 5, 2017 at 17:32
  • 1
    Surely it is the recommended way, and documentation like learn.microsoft.com/en-us/iis/publish/using-web-deploy/… and learn.microsoft.com/en-us/iis/publish/using-web-deploy/… 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
    Commented Nov 2, 2018 at 16:55
23

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/

3
  • 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
    Commented Aug 28, 2014 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
    Commented Nov 2, 2018 at 16:53
  • Valid for this scenery?: My websites and, virtualdirs have certificates for https and hostnames. Some websites are public for internet.
    – Kiquenet
    Commented Aug 18, 2022 at 7: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.

6
  • 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. Commented Mar 6, 2014 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. Commented Mar 14, 2014 at 13:20
  • 1
    But only when deploying site-by-site.... not for an entire server move. Commented Aug 16, 2016 at 1: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
    Commented Dec 5, 2017 at 22:11
  • 1
    I also have no "Deploy" menu after installing the package.
    – user736893
    Commented Sep 26, 2019 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

1
  • I actually used Stuart's answer for a merged migration, I still don't like MS Web Deploy.
    – chews
    Commented Jul 18, 2017 at 8:44
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.

2
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.

3
  • this just gave me errors stating that the default app pool and default web site couldn't be overwritten... no bueno. Commented Jan 14, 2020 at 19:12
  • Try renaming the defaults into something else? and see if they get created with the process explained above?
    – Ralph
    Commented Jan 15, 2020 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
    Commented Aug 5, 2020 at 16:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.