Tuesday, May 20, 2014

Performing Granular Backups using Windows Powershell in SharePoint 2013

I was recently trying to perform a Granular Backup in Windows PowerShell by following this article: http://blogs.msdn.com/b/russmax/archive/2009/10/21/sharepoint-2010-granular-backup-restore-part-1.aspx

Unfortunately, when I ran the command provided in the article, I received the following error message:

Export-SPWeb : The URL provided is invalid. Only valid URLs that are site collections or sites are allowed to be exported using stsadm.exe.

This was unusual because I followed the article exactly and used the exact same syntax for the command.
 
$siteUrl = "http://sp2013alone/sites/teamsite"
$itemUrl = "/My Docs"
$backupFilePath = "C:\Temp\doclib.cmp"
 
Clear-Host
Export-SPWeb -Identity $siteUrl -ItemUrl $itemUrl -Path $backupFilePath -IncludeVersions All -Force


However, I decided to play around with some of the values to see if I could get the command to execute and as it turns out, this was the final command I was able to execute successfully:




$siteUrl = "http://sp2013alone/sites/teamsite"
$itemUrl = "My Docs"
$backupFilePath = "C:\Temp\doclib.cmp"
 
Clear-Host
Export-SPWeb -Identity $siteUrl -ItemUrl $itemUrl -Path $backupFilePath -IncludeVersions All -Force



Notice that I had to remove the beginning “/” from the beginning of the ItemUrl.  Once I removed this character from the beginning of the ItemUrl path, I was able to successfully export the granular backup of my Document Library!

No comments:

Post a Comment