Showing posts with label Backup/Restore. Show all posts
Showing posts with label Backup/Restore. Show all posts

Thursday, September 22, 2016

No content databases in the web application were available to store your site collection

Recently I had tried deleting a site collection and tried restoring the site with the same URL and I got the below error

Restore-SPSite https://sitecollectionurl -Path "E:\filename.bak" -Force

“ Restore-SpSite : The operation that you are attempting to perform cannot be completed successfully. No content databases in the web application were available to store your site collection. The existing content databases may have reached the maximum number of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection. Create another content database for the Web application and then try the operation again “


How to fix this

Restore-SPSite https://sitecollectionurl -Path "E:\filename.bak" -Force –DatabaseServer "DBServerName" -DatabaseName "DBName"

And it worked this time. Site was successfully restored.
This happened because I was trying to restore or create a new site with the same url that was deleted some time back. There is a chance it has not been removed from the database permanently

Alternatively, to delete the old site, do the below steps

Get-SPDeletedSite

If the site exist with the same URL remove using

Remove-SPDeletedSite -Identity

Wednesday, March 23, 2016

Restore-SPSite : 0x80070003

Issue Description

I was trying to do a backup and restore operation between SharePoint farms and got the below error message:

Restore-SPSite : <nativehr>0x80070003</nativehr><nativestack></nativestack>

Resolution

            Make sure that the source and target SharePoint farms are in the same SharePoint build versions.

Thursday, June 18, 2015

Import sites, lists, or document libraries in SharePoint

We can import a site, list, or document library in SharePoint by PowerShell.
Start the SharePoint Management Shell.

Syntax

Import-SPWeb [-Identity] <SPWebPipeBind> -Path <String> [-ActivateSolutions <SwitchParameter>] [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-HaltOnError <SwitchParameter>] [-HaltOnWarning <SwitchParameter>] [-IncludeUserCustomAction <None | All>] [-IncludeUserSecurity <SwitchParameter>] [-NoFileCompression <SwitchParameter>] [-NoLogFile <SwitchParameter>] [-UpdateVersions <Append | Overwrite | Ignore>] [-WhatIf [<SwitchParameter>]]

Example
Import-SPWeb http://site -Path export.cmp -UpdateVersions Overwrite
This example imports the contents of export.cmp into a site at http://site, overwriting the versioned content on the site with the contents of the export.cmp file.


Export sites, lists, or document libraries in SharePoint

We can export a site, list, or document library in SharePoint by using the SharePoint Central Administration website or Windows PowerShell.

Use Windows PowerShell to export a site, list, or document library in SharePoint
To export a site, list or document library by using Windows PowerShell you need to have the below permissions :
securityadmin fixed server role on the SQL Server instance.
db_owner fixed database role on all databases that are to be updated.

1) Start the SharePoint Management Shell.

Syntax

Export-SPWeb -Identity <SiteURL> -Path <Path and File Name> [-ItemUrl <URL of Site, List, or Library>] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose]

Use Central Administration to export a site, list, or document library in SharePoint

Only export one site, list, or document library at a time.
To export a site, list, or document library by using Central Administration, verify that the user account that is performing this procedure is a member of the Farm Administrators group.

1) Start SharePoint Central Administration.

2) In Central Administration, on the home page, click Backup and Restore.

3) On the Backup and Restore page, in the Granular Backup section, click Export a site or list.

4) On the Site or List Export page, in the Site Collection section, select the site collection from the Site Collection list, and then select the site from the Site list.

5) If you are exporting a site, skip this step, Select the list or document library from the List list.

6) In the File Location section, in the Filename box, type the UNC path of the shared folder and the file to which you want to export the list or document library. The file name must use the .cmp extension.

7) If the file already exists and you want to use this file, select the Overwrite existing files check box. Otherwise, specify a different file name.

8) If you want to export all the security and permissions settings with the list or library, in the Export Full Security section, select the Export full security check box.

9) If you want to specify which version of the list or library to export, select one of the following versions from the Export versions list: All Versions , Last Major , Current Version , Last Major and Last Minor


10) When you have specified the settings that you want, click Start Export.

Tuesday, April 7, 2015

Backup a SharePoint Site

Backup SharePoint Site
Backup-SPSite http://sitename -Path E:\Backup\site_name.bak

NAME
    Backup-SPSite

SYNOPSIS
    Performs a backup of a site collection.

SYNTAX
    Backup-SPSite [-Identity] <SPSitePipeBind> -Path <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-NoSiteLock <SwitchParameter>] [-UseSqlSnapshot <SwitchParameter>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

DESCRIPTION

The Backup-SPSite cmdlet performs a backup of the site collection when the Identity parameter is used. By default, the site collection will be set to read-only for the duration of the backup to reduce the potential for user activity during the backup operation to corrupt the backup. 

Restore a SharePoint site to a specific database

Restore a SharePoint site
Restore-SPSite http://sitename -Path "E:\Backup\file.bak" -Force

Restore a SharePoint site to a specific database

Restore-SPSite http://sitename -Path "E:\Backup\file.bak" -Force -DatabaseName "Database"

NAME
    Restore-SPSite

SYNOPSIS
    Restores a site collection.

SYNTAX
  Restore-SPSite [-Identity] <String> -Path <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-ContentDatabase <SPContentDatabasePipeBind>] [-Force <SwitchParameter>] [-GradualDelete <SwitchParameter>] [-HostHeaderWebApplication <String>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

Restore-SPSite [-Identity] <String> -Path <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-DatabaseName <String>] [-DatabaseServer <String>] [-Force <SwitchParameter>] [-GradualDelete<SwitchParameter>] [-HostHeaderWebApplication <String>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

DESCRIPTION

The Restore-SPSite cmdlet performs a restoration of the site collection to a location specified by the Identity parameter. A content database may only contain one copy of a site collection. If a site collection is backed up and restored to a different URL location within the same Web application, an additional content database must be available to hold the restored copy of the site collection.

Tuesday, October 15, 2013

Error while restoring a site collection in the same content database

I wanted 2 sites to be the exact same. So I was performing a backup of a site collection http://sharepoint.fahad.com/sites/siteA and was trying to restore it as http://sharepoint.fahad.com/sites/siteB .


Backup-SPSite -Identity "http://sharepoint.fahad.com/sites/siteA" -Path "C:\ Backups\siteA.bak” -force -verbose

Restore-SPSite -Identity "http://sharepoint.fahad.com/sites/siteB" –Path "C:\ Backups\siteA.bak" -force -verbose

The restore operation failed and gave me the below error:

Restore-SPSite: The operation that you are attempting to perform cannot be completed successfully.  No content databases in the web application were available to store your site collection.  The existing content databases may have reached the maximum number of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection.  Create another content database for the Web application and then try the operation again.

Reason

Both these site collections were in the same web application and it had only one content database. Microsoft uses the source site collection GUIDs during the installation. Though you delete the site collection from the web application, it leaves the GUIDs behind, and if you try to restore same site collection (same GUID) into same web application and content database, it would throw an error.

To resolve the issue, new content database needs to be created in the web application to restore the site collection.

Resolution

1.Create a new content database WSS_Content_siteB from Central Administration for your web application where your site collection is going to reside. Reference


2.Restore-SPSite -Identity "http://sharepoint.fahad.com/sites/siteB" -Path "C:\ Backups\siteA.bak" -force -verbose -ContentDatabase WSS_Content_siteB