Skip to main content

From The Field

Go Search
From The Field
  

From The Field > Categories
mergecontentdbs gotcha

Back in SharePoint 2007 Service Pack 1, a new command “stsadm –o mergecontentdbs” was released to help administrators move a site collection from one content database to another. (Despite its name it doesn’t actually merge content databases, just moves the data from one content database to another.) This was fine as long as the size of the site collection being moved was not too big.

 

It might take several hours to perform the whole move for a large site collection. Plus if for any reason the job crashed out during its run you could be left with orphans in either of your content databases or neither of them in working state. See http://support.microsoft.com/kb/969242/ for more information.

 

Recently I helped a customer upgrade their SharePoint system to SP2 with the June 09 Cumulative Update and once this was done, to move a 20Gb site collection to a new content database.

 

The move worked correctly and the “stsadm –o mergecontentdbs” command returned without error. Looking in the new content database I could see the data and an entry in the “sites” table which showed that this contentdb did in fact contain the moved site collection. Looking in the old contentdb at its “sites” table indeed showed that the site collection was gone.

 

So what was the problem?

 

It became clear that once the move was over, we were unable to shrink the size of the old content database. It still contained over 20Gb of data and I had no idea why it was still there.

 

Running a “stsadm –o databaserepair” command against the old content database showed 1000’s of orphans and upon closer inspection these where all individual sites (SPWeb objects) which had been part of the moved site collection. Running “stsadm –o databaserepair” this time again with the “-deletecorruption” switch did the job of removing the orphans after which we could shrink the old content database.

 

Therefore it would seem that the way the “stsadm –o mergecontentdbs” command works between SP1 and SP2 + June 09 CU seems to have changed. Indeed it seems to deliberately create orphans as part of the move.

 

After speaking to some of the guys on my team (hat tip to Andy D) the following blog posting came to light from the team at Microsoft who maintains the documentation you see on TechNet.

 

http://blogs.technet.com/tothesharepoint/archive/2009/05/21/3244169.aspx

 

It makes mention of the way the mergecontentdbs command was changed in the April 09 Cumulative Update and that it is now the default behaviour to leave the data in the old content database and rely on a new timer job to delete the data automatically in the background. The role of this job is to simply clean up orphans of a particular type which are generated as part of the call to mergecontentdbs.

 

In summary: Systems which have at least Service Pack 2 and the April 09 Cumulative Update will by default rely on a timer job to remove data from old content databases when the “stsadm –o mergecontentdbs” command is used to move a site collection from one database to another.

Mergecontentdbs - Potential issue with data corruption

The stsadm operation mergecontentdbs was introduced with SP1 - http://technet.microsoft.com/en-us/library/cc262923.aspx , this operation can be used to move site collections between content databases. Which is really useful when re-organizing content databases to maximize performance. Recently a potential issue has come to light with this operation when used with site collections that are larger than 10GB which can potentially lead to data corruption in certain cases; this is documented in the following KB article - http://support.microsoft.com/default.aspx?scid=kb;EN-US;969242

One of the recommendations to avoid this issue is to use Batch Site Manager to move site collections that are smaller than 15GB between content databases; this tool is part of the SharePoint Administration Toolkit and can be downloaded from - http://www.microsoft.com/downloads/details.aspx?familyid=BE58D769-2516-43CB-9890-3F79304528FF (x64) and http://www.microsoft.com/downloads/details.aspx?familyid=412A9EF1-3358-4420-B820-0CA3F4641651 (x86)

Two important KB articles released recently relating to backup and restore

Two important KB articles have been released recently that relate to the important topic of backup and recovery.

Stsadm can inadvertently delete a root site collection if erroneous URL path used - http://support.microsoft.com/default.aspx/kb/968474

After using stsadm -o restore with the -overwrite parameter and getting an error you notice a site one level up from the site you were trying to restore is deleted.  The root level site http://servername  is deleted. The site that you were attempting to restore was http://servername/sites/sitename

This can happen if you pass an invalid URL to the stsadm –o restore command, for example http://servername/site/sitename instead of the correct URL of http://servername/sites/sitename

Microsoft Office SharePoint Server 2007 unsupported scenarios using stsadm -o export /import of subsites - http://support.microsoft.com/kb/968483

In basic terms you cannot use stsadm –o import to restore a sub-site to a root site collection if the publishing feature is enabled, this procedure is generally used to re-organize content.

The supported method to achieve this is to restore the sub-site to a sub-site within a site collection that has the publishing feature enabled and then copy across any master pages or page layouts that the sub-site relies on to the destination site collection.

 

Configuring Usage Analysis Processing using stsadm

I ran into a problem recently when attempting to enable and configure Usage Analysis Processing (UAP)using stsadm, I needed to do this as part of a fully scripted installation of MOSS 2007 that I was assisting a customer with. Looking at the stsadm documentation, the following commands are available:

stsadm -o setproperty

   -propertyname usageprocessingenabled

   -propertyvalue {Yes | No}

stsadm -o setproperty

   -propertyname job-usage-analysis

   -propertyvalue {Yes | No}

I then ran the following two commands to configure UAP:

stsadm -o setproperty -pn job-usage-analysis -pv "daily between 08:00 and 09:00" To configure the time that the process runs.

stsadm -o setproperty -pn usageprocessingenabled -pv "Yes” To enable Usage Analysis Processing.

However when I browsed to Central Administration – Operations – Usage analysis processing the following was displayed L

If you look closely you can see that the time has been set correctly but it hasn’t enabled usage analysis processing. As you can see this is grayed out meaning that Enable logging must be selected before it can be enabled – but how do I enable logging? After much investigation I eventually found out (from a colleague- thanks Kirk) that the following stsadm can be used to enable this.

stsadm -o setproperty -pn loggingenabled -pv "Yes”

To put this all together I need to run the commands in this order to achieve my objective:

·         stsadm -o setproperty -pn loggingenabled -pv "Yes”

·         stsadm -o setproperty -pn job-usage-analysis -pv "daily between 08:00 and 09:00"

·         stsadm –o setproperty -pn usageprocessingenabled -pv "Yes”

Success!

Brendan Griffin

STSADM Catastrophic Backups Failing

I recently came across an issue with a customer with their nightly stsadm farm (Catastrophic) backups which were failing.

 

They were using the following stsadm command to create the backups -

 

stsadm -o backup

   -directory <UNC path or local drive>

   -backupmethod <full or differential>

   [-item] <created path from tree>

   [-percentage] <integer between 1 and 100>

   [-backupthreads] <integer between 1 and 10>

   [-showtree]

   [-quiet]

I took a look at the backup log file that is generated during the backup (spbackup.log)  and found that the backups were backing up all components successfully but were pausing at the Index backup step for 3600 seconds (1 Hour).

I took a look in the Application Event Log and found the following entry, this occurred prior to the backups initially starting to fail.

A master merge cannot be started for catalog AnchorProject due to error The file exists. 0x80070050

To resolve the issue I launched the SSP Administration site (the customer had a single SSP) selected Search Settings, I then went into Search Settings.

Within Search Settings there is an option to Reset All Crawled Content, I selected this, and once the Index had been reset I performed a manual Full Crawl.

WARNING: Resetting the Index will delete the Index and end users will not be able to search content until a Full crawl has been performed, depending on the amount of data to be indexed this could take a significant amount of time.

I them ran a stsadm catastrophic backup which successfully backed up all components – including the Index J

Stsadm - Piping Hot

Ever found yourself wading through all those stsadm commands wondering which one you need?  Ever wish you could search one page of commands at a time?  Did you know you can pipe stsadm?  You didn't?

Piping

I think piping comes from Unix originally but it got included in MSDOS.  The pipe sign is this: | .  I've been reading Real World SharePoint 2007 and Todd Klindt writes a magic chapter about MOSS admin.  He shows piping stsadm to find so you can search for keywords in the commands.  Like this:

stsadm | find "delete"

deleteadminvs
deletealternatedomain
deletecmsmigrationprofile
deleteconfigdb
deletecontentdb
deletegroup
deletepath
deletepermissionpolicy
deletesite
deletesolution
you get the idea....

stsadm | more

You can also use 'pipe to more' to paginate the stsadm output.  This will display one page and then prompt you to press a key go to the next.  This is handy when you don't a clue what you are looking for.

 

Redirecting

You can send your stsadm output to a text file by using the redirecting command > like this:

stsadm > file >&

This can be handy to record errors for troubleshooting if you're expecting them.  Try this:

stsadm -o export -filename export.cab > error.txt 2>&1

This will produce a command line error because I left out the -url switch required for an stsadm -o export.  The error will be written to the error.txt file.  In the example above the > error.txt part of the command names the file to redirect to.  The 2>&1 uses handles to redirect the error output to the file.

Thanks to MCS guru Mark Arend for this tip.  Check for more detail on redirecting, handles and piping here:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

 

Enumerating

You can list objects by using the emun commands with stsadm.  There are lots of them.  For example, If you wanted to list all the content databases being used in web app:

stsadm -o enumcontentdbs -url http://portal

You'll notice the output is always in XML markup when you use an enum.  So if you were to redirect the output to a file it may as well have an xml extension.

 

Putting it together

Here's another example that puts some of the commands together.  This time we want to list all the roles in a site collection.  

  1. First, remind yourself which enum command lists roles:
    stsadm | find "enum"
  2. From that you find the enumroles command
  3. Then use stsadm to list the roles and write the output to an XML file
    stsadm -o enumroles -url http://portal > roles.xml 2>&1
Moving Sites with STSAdm (my new best mate)

Had two situations recently where I needed to move sites around a farm so I turned to my old pal STSAdm.exe for help.

Move Top Level Site to Sub Site

First, I had a top level site in it's own web application that needed to be a sub-site in another web application.  I've illustrated in the graphic below.  We had to move Site 1 from Site Collection 1 to Site Collection 2.

 

To export I used:

  • stsadm.exe -o export -url http://Site1 -filename Site1.cab -versions 4

To import I used:

  • stsadm.exe -o import -url http://SiteA/Site1

Notes

  1. If http://SiteA/Site1 already exists when you do you import you may see an error telling you the templates don't match.  This means the export site was created using a different template to the one that exists in the new location.  To workaround this back up and delete http://SiteA/Site1 then run the import again.
  2. Any content that hasn't been approved will not be exported by default.  I used the -versions 4 switch to export all major, minor and draft versions.  You might not need to do this.

Move Sub Site to Top Level Site

Next I needed to move a sub site in Site Collection 1 and move it into an empty Web Application 2.  In the figure below we had to move Site C from Site Collection 1 to Site Collection 2.

 

For the export I used:

  • stsadm -o export -url http://SiteA/SiteC -filename SiteC.cab -versions 4

Because there was no site collection I created one with STSAdm without choosing a template.  Like this:

  • stsadm.exe -o createsite -url http://SiteC -ownerlogin domain\administrator -owneremail administrator@domain.com -title Site C

That way you don't get any template clashes when you do your import:

  • stsadm.exe -o import -url http://SiteC -filename SiteC.cab

Notes

  1. An export should take all content with it.
  2. UPDATE 25/09/07 Custom features that have been installed on the source server will need to be packaged up and installed on the target before the import will work.
  3. UPDATE 07/10/07 It does matter which account you use for the export.  Strangely, if you don't have the right access the command runs successfully but the export file has got nothing in it.  The import doesn't fail either, but you can't find the site you thought you exported.   I've tried with an account that had local admin rights and was a site collection admin, but that isn't enough.  Always use the farm account.

 Error

Web Part Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.

Error Details:
[UnsafeControlException: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.]
  at Microsoft.SharePoint.ApplicationRuntime.SafeControls.GetTypeFromGuid(Guid guid)
  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts)