Recently, a colleague requested that I perform a backup of a development site collection at http://sp.ad.local and restore it to the test site collection http://test.ad.local/sites/sp.
The test site collection was one of two site collections on the test.ad.local web app. It’s been a while since I’ve done anything in SharePoint, so I took a look then ran the following.
Backup-SPSite -Identity http://sp.ad.local -Path \\fileshare\sp.bak Restore-SPSite -Identity http://test.ad.local/sites/sp -DatabaseName WSS_Content_Test -path \\fileshare\sp.bak –Force -Confirm:$false
Admittedly, I was suspicious of the -DatabaseName param I was passing, because that database contained two site collections, and I was only attempting to restore one. Sure enough, the attempted restore gave me the following error:
Restore-SPSite: The site collection could not be restored. If this problem persists, please make sure the content databases are available and have sufficient free space.
Beware: This destroyed the /sites/sp site collection. Attempting to load it gave me a 404 Not Found. Honestly, I was a little blasé about the restore since it was to a test site. So I tried a few things to remedy the issue, and then figured that it would probably work if I isolated the site collection to its own database.
New-SPContentDatabase -Name WSS_Content_Test_SP -WebApplication http://test.ad.local Move-SPSite -Identity http://test.ad.local/sites/sp -DestinationDatabase WSS_Content_Test_SP Restore-SPSite -Identity http://test.ad.local/sites/sp -DatabaseName WSS_Content_Test_SP -path \\fileshare\sp.bak –Force -Confirm:$false