共用方式為


IIS 6.0 Recovering websites from a stale metabase.xml

     The metabase is a repository for most IIS configuration settings. It resides as a plaintext XML file metabase.xml in the systemroot\System32\Inetsrv folder. All the websites and their corresponding settings are stored in this file.
     The problem with this file is that even though it is plain text xml we cannot copy it over from one server to another to get the website settings to the new server. Also if you reinstall IIS you cannot use an old metabase.xml backup to restore the websites and settings. The reason? If you open up metabase.xml you will find tags in it called "AdminACL". This is the Access Control List that is encrypted using the current "Machine Keys" (C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys) on the server. So if you reinstall IIS or move the metabase.xml to another server IIS will not be able to decrypt the access control list and hence will not be able to load the metabase. So you end up in a situation where the IIS service will not start.
     So what do we do when we have a server crash and end up reinstalling IIS? You now have a new set of Machine Keys and are left with a stale metabase.xml that cannot be used. Even tools like MetabaseExplorer and MetaEdit will not allow you to load or import the stale metabase.
     What we can do is play around with the current working metabase.xml file (remember it is still plaintext) and copy paste the necessary tags from the old stale metabase.xml and get "almost all" of the settings back. But it is a tedious work and consider scenarios where the IIS server is hosting multiple sites.
     I was once in a similar situation where I had to restore 883 websites and 182 FTP sites from a backup metabase.xml file onto a reinstalled IIS instance.
     So I have written a small console app that would do the same. It copies websites/ftp sites and web service extensions from any metabase.xml into the current metabase.xml

USAGE : It is a console application so unzip the attached MetaBaseImport.zip in a folder. Copy the current working metabase.xml and the backed up metabase.xml into the same folder. Then run

Metabaseimport <current_metabase.xml> <old_metabase.xml>

This will generate a file called NewMetaBase.xml with the Server Settings of the current working metabase.xml and the websites/ftp sites from the old metabase.xml. Stop IIS services. Replace the metabase in the inetsrv folder with the NewMetaBase.xml and start the IIS services. You will have all the old sites.

Note: All secure entries like IUSR/IWAM/UNC UserName and Passwords. In case you had custom entries you will have to manually add them again.

While this application is not perfect it manages to do most of the dirty stuff. Let me know if you find it useful.

Bookmark and Share

MetaBaseImport.zip

Comments

  • Anonymous
    August 08, 2007
    Great tool!! Awesome work. Saved me lots of time restoring a webserver.

  • Anonymous
    September 05, 2007
    Great tool. I have one question. Can we use this tool also for virtual directories.

  • Anonymous
    September 23, 2007
    Nice...

  • Anonymous
    September 26, 2007
    Cool!

  • Anonymous
    December 17, 2007
    Excellent! Just what I needed!

  • Anonymous
    January 09, 2008
    Thanks heaps. Smooth transition.

  • Anonymous
    January 17, 2008
    You are the MAN!!!. I have searched the internet all over the place and I could not find anything like this. Thank you so much for giving so much value to the world.

  • Anonymous
    June 02, 2008
    Thanks for the tool!  One small issue is that if you have 2nd level virtual directories, it misses the entry for the IIsConfigObject that has the parent folder name.  This causes any 2nd level virtuals to not be setup.

  • Anonymous
    June 18, 2008
    You know... this thing just made my day....

  • Anonymous
    September 10, 2008
    You ARE AWESOME... This file saved my day.. Thanks a LOT.

  • Anonymous
    September 19, 2008
    Thanks, expected someone would have been in the same boat! In my case, I was left with a couple of UNC password entries flagged in the event log that were still preventing IISAdmin startup.  Removed them and it started and loaded all the sites! Thanks for this great tool!

  • Anonymous
    October 30, 2008
    Just wanna say thanks like the rest, just made 6 identical servers in 2 min... Super Nice...

  • Anonymous
    November 10, 2008
    Thanks! After a good couple of hours battling - your tool was the trick i needed to recover my exchange. THANKS!!!

  • Anonymous
    June 10, 2009
    Thanks a lot for sharing this great tool!!!

  • Anonymous
    December 10, 2009
    I was ready to start picking apart the old metabase file and you saved me so much time! Thanks!

  • Anonymous
    May 09, 2012
    Shinva, thank you very much for writing this script! You've saved me so much time with this! Regards, Liam

  • Anonymous
    May 21, 2012
    Brilliant!  Thank you! UNC password issues were still there, but after I cleaned those up.  Bingo!  Thanks again!

  • Anonymous
    May 29, 2014
    The comment has been removed

  • Anonymous
    October 23, 2014
    The comment has been removed

  • Anonymous
    December 18, 2014
    The migration from old to new worked great, however, I'm still unable to start IIS.  I removed the UNC password as suggested below (I commented out the entire custom section for the UNCpassword), but I'm still not gettin IIS to start.