I tried to rename the site collection host header (see post here) and it did not work, so I found this blog and thought I could give Backup-SPSite, Remove-SPSite and Restore-SPSite a try. I used this code below, of course changed the values.

Backup-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak 
Remove-SPSite –Identity http://server_name/sites/site_name –Confirm:$False 
Restore-SPSite http://www.example.com -Path C:\Backup\site_name.bak -HostHeaderWebApplication http://server_name 

When I tried to restore it back, it said that it could not open database

Restore-SPSite : Cannot open database "SP_Content_1" requested by the login. The login failed. Login failed for user 'domain\svc_farm'. At line:1 char:1 + Restore-SPSite https://newsite -Path D:\backupsite.bak -HostHeader ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Share...dletRestoreSite:SPCmdletRestoreSite) [Restore-SPSite], SqlException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreSite

The database SP_Content_1 does not exist actually. How is it trying to log in when it does not exist? Therefore, I created a database, gave the user access to the database and tried it again.

Restore-SPSite http://www.example.com -Path C:\Backup\site_name.bak -HostHeaderWebApplication http://server_name

This time I am getting the following error.

Restore-SPSite : Invalid object name 'Sites'. At line:1 char:1 + Restore-SPSite https://sitename.com -Path D:\backupsite.bak -HostHeader ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Share...dletRestoreSite:SPCmdletRestoreSite) [Restore-SPSite], SqlException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreSite

The environment is the same one. I have used the Get-SPDeletedSite and there are no deleted sites as I cleared them all.

Any idea how should I proceed from here?


try to use something like this:

Restore-SPSite -Identity http://newurl -DatabaseServer "SQLS01\instance" -Path D:\backup.bak -DatabaseName "SP_Content" -HostHeaderWebApplication https://webapphostheaderurl

I have included the databaseserver and databasename in the script. Let us know what you get.

  • it worked!! but I am getting this warning: WARNING: The port specified for the new host header site does not match any known bindings in the specified Web Application. The new site will not be acce ssible if the Web Application is not extended to an IIS Web Site serving this port. Dec 20 '17 at 14:56
  • Is ur hostname site collection using different port than the web application itself?
    – Waqas Sarwar MVP
    Dec 20 '17 at 15:06
  • no it is using the same port. 443 Dec 20 '17 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.