Monday, February 16, 2015

The specified URL is not a top-level Web site

While doing site Backup and Restore in SharePoint 2013, i was getting the following error. Please note that the site collection is Host Name Site collection not Path based site collection.

The command i was giving is

PS C:\Windows\system32> Restore-SPSite http://sites.mytestsites.com/sites/mytestsite1 -Path "D:\Backup\MYTESTSITE1-PROD-20150210-2351.bak" -DatabaseName "SP13_Content_TESTSITEDB" -HostHeaderWebApplication "http://WFESERVERNAME" -Force 

The specified URL is not a top-level Web site. The backup and restore operations work only for top-level Web sites. Enter the URL for a site to try the

operation again.

At line:1 char:1
+ Restore-SPSite http://sites.mytestsites.com/sites/testSite1 -Path "D:\Backup\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...dletRestoreSite:SPCmdletRestoreSite) [Restore-SPSite], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreSite

The only thing that worked for me is 

- Deleting the existing site collection using the Remove-Spsite powershell cmdlet.
- Restoring the site from Backup using Restore-Spsite powershell cmdlet targeting to specific content DB

Remove-SPSite -Identity "http://sites.mytestsites.com/sites/TestSite1" -GradualDelete

Restore-SPSite http://sites.mytestsites.com/sites/MyTestSite1 -Path "D:\Backup\MyTestSite1.bak" -DatabaseName "SP13_Content_TestSitesContentDB" -HostHeaderWebApplication "http://WFESERVERNAME"

Hope this helps for some one who is having similar issue in backing up and restoring Host Name Site Collection (HNSC)

If someone finds a reason for this or is there any other way of doing this restore please let me know. 

Thanks,

Vinay. 

Friday, February 13, 2015

Export-SpWeb : The URL provided is invalid


While running the Export command for exporting the list from one site to another, i was giving the exact syntax but giving me the following error.

Export-SPWeb http://sites.sp13.com/sites/MyDevSite -Path "D:\SharePointBackUps\MyTestList.bak" -ItemUrl "http://sites.sp13.com/sites/MyDevSite/Lists/MyTestList" -IncludeUserSecurity -IncludeVersions All

Export-SPWeb : The URL provided is invalid. Only valid URLs that are site collections or sites are allowed to be exported using
stsadm.exe.
At line:1 char:1
+ Export-SPWeb -Identity http://sites.sp13.com/sites/myDevSite -Path "D: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...CmdletExportWeb:SPCmdletExportWeb) [Export-SPWeb], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletExportWeb

Annoying, isn't it?

After reading the some of the blogs, the following link helped me
http://blogs.msdn.com/b/briangre/archive/2014/03/18/export-spweb-syntax-changes-between-root-site-and-sub-sites.aspx 

After giving the following syntax it worked. The issue occurring at -ItemUrl parameter. After giving in the format Lists/LISTNAME it worked.

Export-SPWeb http://sites.sp13.com/sites/MyDevSite -Path "D:\SharePointBackUps\MyTestList.bak" -ItemUrl "Lists/MyTestList" -IncludeUserSecurity -IncludeVersions All

Why??
The reason is at the background Get-SPWeb cmdlet is calling SPWeb.GetList(), before calling this function it prepends SPWeb.ServerRelativeUrl and an extra forward slash "/".

HTH

Vinay.