Friday, June 28, 2013

Change Site Definition

When an upgrade is performed on a SharePoint environment chances are some items will get lost in the upgrade.  This is especially true if your 2007 environment took advantage of the FAB40 template set or someone went crazy downloading free site templates from the internet.  These items do not block a successful upgrade and sites may even continue to work as expected after the upgrade has been performed.  However these do leave your content databases in a weird state and central administration does warn about these missing items so it is best to cleanup your content databases to remove these broken references.  There are a number of possible errors that can be presented and for most of them the way to resolve the problem is straight forward.  For reference I have included these here.

MissingWebPart and Missing Assembly
MissingFeature
MissingSetupFile

However there is no well known process for dealing with MissingSiteDefinition references which look like this message:

[MissingSiteDefinition] 1 Sites in database [] has reference(s) to a missing site definition, Id = [75820], Lcid = [1033].  The site definitions with Id 75820 is referenced in the database [], but is not installed on the current farm. The missing site definition may cause upgrade to fail. Please install any solution which contains the site definition and restart upgrade if necessary.

The site definition does not seem to be used or depended on anywhere inside of SharePoint, it only seems to be used for loading resources from the 14 hive.  However there is no way through stsadm or powershell to change the site definition for an existing site which means once a site is created there is no way to change the site definition.  This can be very troublesome because a lot of backup / restore and import / export commands require an existing site with the same site definition as the original, making these processes impossible to execute on sites with a missing site definition.  If you find yourself in this situation I have developed this process for changing the site definition of a site back to a blank site.

NOTE: This process involves editing files that Microsoft does not support editing for, so this process is use at your own risk.  Make sure to implementing extensive testing before deleting the original content.

  1. Create a new blank site that will be used for testing. 
  2. In powershell export original site: Export-SPWeb http://site.url/ -IncludeVersions 4 -IncludeUserSecurity -path \\put\files\here -NoFileCompression (Exporting with no file compression is the key make sure to include it)
  3. Edit Manifest.xml change the Configuration attribute to 1 if it is another number. 
  4. In the Manifest.xml file change the attribute WebTemplate to "STS" 
  5. Edit Requirements.xml change the attribute WebTemplate ID to STS#1 
  6. In powershell import into the previously created blank site: Import-SPWeb https://blank.url/ -path \\put\files\here -NoFileCompression -IncludeUserSecurity 
  7. Verify test site! 
  8. Delete original site 
  9. Create new blank site with original site's url and site collection administrators
  10. Import into the just created blank site using same command and files as in step #5 
  11. Verify new site
  12. Empty recycle bins

2 comments:

lee woo said...

Love is when he gives you a piece of your soul, that you never knew was missing. See the link below for more info.


#missing
www.ufgop.org

Silvia Jacinto said...

Life is a battle, if you don't know how to defend yourself then you'll end up being a loser. So, better take any challenges as your stepping stone to become a better person. Have fun, explore and make a lot of memories.

n8fan.net

www.n8fan.net