Friday, December 18, 2015

Restore-SPSite error "0x80070003" - Solution

With this post I would like to share with you another strange issue with SharePoint 2013 and restoring site collection. The scenario in my case was:
  • I have a site collection with missing files
  • Last available SQL backup  - 3 months ago
So at the beginning restoring the missing files looks an easy task. I restored the content DB in SQL with different name and made a backup of the site collection (Central Admin -> Backup and Restore -> Recover data from an unattached content database). My goal was to restore the site collection under different URL, but when I tried to restore it the following error poped up:

PS H:\> Restore-SPSite http://test.contoso.com/sites/scr -Path D:\Backups\sitecollection1.bak
Confirm Are you sure you want to perform this action? Performing operation "Restore-SPSite" on Target "http://test.contoso.com/sites/scr". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
**Restore-SPSite : <nativehr>0x80070003</nativehr><nativestack></nativestack> At line:1 char:1 + Restore-SPSite http://test.contoso.com/sites/scr -Pat ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : InvalidData: (Microsoft.Share...dletRestoreSite: SPCmdletRestoreSite) [Restore-SPSite], DirectoryNotFoundException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreS ite**

This error message means that the backup of the site collection has older schema version then the current SharePoint. Actually the all content DB needs to be updated to the current SharePoint version in order to be able to do something with the backup otwerwise the backup is useless. As a next step you need to mount the content DB to existing or new web application and upgrade the database. I strongly recomend you to use powershell for these two steps:
  1. Mount the content DB with Mount-SPContentDatabase and AssignNewDatabaseId parameter, otherwise the cmdlet will trown error because there is already a DB with the same ID.
  2. Upgrade the DB with Upgrade-SPContentDatabase -Identity <DB name>
I strongly recommend you to check the upgrade logs, placed in the ULS folder. You have to discover a lot of the errors like this:
12/14/2015 18:36:20.12 powershell (0x20550) 0x26A38 SharePoint Foundation Upgrade SPContentDatabaseSequence ajxk1 ERROR Database [RM_SP_Content_02] contains a site (Id = [50340533-6c00-4187-8d01-f9eabdc514ed], Url = [/sites/scr]) whose id is already associated with a different database (Id = [95823bf0-4fe2-462e-bdf9-bb37b35b4c26], name = [SP_Content_02]) in the site map. Consider deleting one of these sites which have conflicting ids. d642bc3b-5bf4-4783-82da-47030365bb9b
I would say that all these errors are OK, because most of the sites still exist in SharePoint. But even the upgrade was successful you won't be able to browse or backup the site collections inside the restored content DB. As a next step unmount the content DB from SharePoint (Dismount-SPContentDatabase or use Central Admin) and backup your site collection via Unattached Content Database Data Recovery in Central Admin. After you backup your site collection you will be able to restore it with Restore-SPSite. 
Please share if you think this post is useful.

No comments:

Post a Comment