Friday, December 17, 2010

IIS7: How to backup and restore one website on IIS7 ..or "the single most important use of appcmd"

Microsoft didn't make it easy for us when it came to facilitate the very important task of backing up one single website on IIS7 to later be able to restore it to a new server...

They didn't even make it easy if you wanted to backup the whole server configuration. In this case you follow the instructions posted in here.

So How was it on IIS6 ?

But when all you want to do is backup ONE SINGLE WEBSITE, with all it's Virtual Directories, all it's settings, passwords, mime types, chaching rules, etc... if you still have II6, you can do like this:


to create the XML file, wich we'll edit to change the SITE ID and SITE NAME or even the HOST NAME to avoid later a conflict when we restore that XML file as new website like this:


But how is it on IIS7 ?

On new IIS7... this is not possible via GUI ...we have to do it the old fashioned way, by typing commands on the CMD console...(running as administrator if you are on Win7 or WinServer2008)

Gotta do as follows:
Go CMD on windows (as adminsitrator) and go to the IIS install folder (say C:\windows\system32\inetsrv\) and type:
appcmd list site

This will list all the sites on the server.... take note of the ID for these sites, the new site you create must have a new ID.
arcpmd list site "myOldSite" /config /xml > myXMLFile.xml
This will create a file named "myXMLFile.xml" on the current IIS Install folder
Edit (with notepad maybe) this file and change the ID values on the XML so it won't conflict with any of the sites previously listed. Also change the name of the site and the binding information..
appcmd add site "myNewSite" /in < myXMLFile.xml
this will take that XML File and turn it into a new website on the server .... a perfect replica of the original ...

This Post helped me a lot understanding the arcpmd command

2 comments:

  1. Hi there, nice post and a good source of information. It really shows that you're an expert in this field. I'm looking for some tips on how to do a full site backup wordpress in this site. Thanks for sharing. Keep it up!

    ReplyDelete
  2. This article is an engaging abundance of enlightening information that is intriguing and elegantly composed. I praise your diligent work on this and thank you for this data. You have what it takes to get consideration.  Website Backup

    ReplyDelete