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


Comments (20)

  1. Alex says:

    Great tool!! Awesome work. Saved me lots of time restoring a webserver.

  2. Quidad says:

    Great tool. I have one question. Can we use this tool also for virtual directories.

  3. shakeel says:

    Excellent! Just what I needed!

  4. ideg says:

    Thanks heaps. Smooth transition.

  5. Aramis says:

    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.

  6. JP says:

    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.

  7. You know… this thing just made my day….

  8. Hitesh Bhardwaj says:

    You ARE AWESOME… This file saved my day..

    Thanks a LOT.

  9. Glynn says:

    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!

  10. Thomas says:

    Just wanna say thanks like the rest, just made 6 identical servers in 2 min… Super Nice…

  11. Damian says:

    Thanks! After a good couple of hours battling – your tool was the trick i needed to recover my exchange. THANKS!!!

  12. Dieter says:

    Thanks a lot for sharing this great tool!!!

  13. melikeum says:

    I was ready to start picking apart the old metabase file and you saved me so much time! Thanks!

  14. Liam B says:

    Shinva, thank you very much for writing this script! You've saved me so much time with this!



  15. Justin says:

    Brilliant!  Thank you!

    UNC password issues were still there, but after I cleaned those up.  Bingo!  Thanks again!

  16. Chris says:

    Hi there,

    This process is not working for me because after I followed the process, I am getting an error: "Error Parsing the XML file. Reason: A name was started with an invalid character."

    I am going from a windows 2003 to a windows 2008 server running IIS 6

  17. Gage says:

    DID NOT WORK. I think all those comements are crap.

  18. Sean says:

    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.

Skip to main content