How To Export/Import a Website in IIS 7.x

Posted by Tray Harrison on Geeks with Blogs See other posts from Geeks with Blogs or by Tray Harrison
Published on Tue, 11 Jan 2011 21:04:38 GMT Indexed on 2011/01/11 21:55 UTC
Read the original article Hit count: 245

Filed under:

IIS 6 had a great feature called ‘Save Configuration to a File’ which would allow you to easily export a website’s configuration, to be later used to import either on the same server or another box.  This came in handy anytime you wanted to duplicate a site in order to do some testing without impacting the existing application.  So naturally, Microsoft decided to do away with this feature in IIS 7.

The process to export/import a site is still fairly simple, though not as obvious as it was in previous versions.  Here are the steps:

1. Open a command prompt and navigate to C:\Windows\System32\inetsrv and run the following command:

appcmd list site /name:<sitename> /config /xml > C:\output.xml

So if you were wanting to export a website named EAC, you would run the following:

image

If you’ll be setting up another copy of the site on the same server, you’ll now need to edit the output.xml file before importing it.  This is necessary in order to avoid conflicts such as bindings, Site ID, etc.  To do this, edit the XML and change the values.  Go ahead and make a copy of the home directory, and rename it to whatever folder name you specified in the output – /EAC2 in this example.  If you decide to change the app pool, make sure you go ahead and create the new app pool as well.

image

Once these edits have been made, we are now ready to import the site.  To do that run:

appcmd add sites /in < c:\output.xml

So for our example it would look like this:

image

That’s it.  You should now see your site listed when opening up Inet Manager.  If for some reason the site fails to start, that’s probably because you forgot to create the new app pool or there is a problem with one of the other parameters you changed.  Look at the System log to identify any issues like this.

© Geeks with Blogs or respective owner