System.IO.DirectoryNotFoundException while SharePoint site restore

If you are trying to restore a SharePoint site backup using SharePoint PowerShell
e.g. Restore-SPSite -Identity -Identity "http://sitecollectionurl" -Path "C:\BackupPath\backup.bak" 
then if the source and target version are not in sync then it can throw below exception.
 
System.IO.DirectoryNotFoundException: <nativehr>0x80070003</nativehr><nativestack></nativestack>
at Microsoft.SharePoint.Library.SPRequestInternalClass.GetSiteFlags(String bstrUrl)
at Microsoft.SharePoint.Library.SPRequest.GetSiteFlags(String bstrUrl)
at Microsoft.SharePoint.SPSite.Delete(SPSiteDeleteFlags flags)
at Microsoft.SharePoint.SPSite.Delete()
at Microsoft.SharePoint.SPSite.Restore(String filename, Boolean isADMode, Boolean& readOnlyMode, Boolean& hadWriteLock)
at Microsoft.SharePoint.Administration.SPSiteCollection.Restore(String strSiteUrl, String strFilename, Boolean bOverwrite, Boolean bGradualDelete, Boolean hostHeaderAsSiteName, Boolean preserveSiteId)
at Microsoft.SharePoint.PowerShell.SPCmdletRestoreSite.InternalProcessRecord()
at Microsoft.SharePoint.PowerShell.SPCmdlet.ProcessRecord()
 
The reason for this error is in ULS logs just before this exception,
 
Could not deserialize site from C:\Sitebackup\rootsite.bak . Microsoft.SharePoint.SPException: Schema version of backup 15.0.4823.1003 does not match current schema version 15.0.4833.1000 at Microsoft.SharePoint.SPSite.Restore(String filename, Boolean isADMode, Boolean& readOnlyMode, Boolean& hadWriteLock) 
 
To avoid this error the source and target SharePoint farm should be on the same version, build. Once can check these version in "Manage Servers in this farm" section of Central Admin.
 
One can try to bring the source and target version to same build or one can use the DB attach method for restoring the site collection. 
Ebook Download
View all
Learn
View all