Restore-SPSite

Restores a site collection.

Syntax

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

Description

This cmdlet contains more than one parameter set. You may only use parameters from one parameter set and you may not combine parameters from different parameter sets. For more information about how to use parameter sets, see Cmdlet parameter sets.

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.

Examples

----------------------EXAMPLE 1----------------------

Restore-SPSite https://server_name/sites/site_name -Path C:\Backup\site_name.bak

This example restores a site collection from the backup file C:\Backup\site_name.bak to the site collection URL https://server_name/sites/site_name.

----------------------EXAMPLE 2----------------------

Restore-SPSite https://server_name/sites/site_name -Path C:\Backup\site_name.bak -Force -DatabaseServer SQLBE1 -DatabaseName SQLDB1

This example restores a site collection backup from the backup file C:\Backup\site_name.bak, but overwrites the existing site collection at https://server_name/sites/site_name while specifying that the site collection must be stored in a specific content database.

----------------------EXAMPLE 3----------------------

Restore-SPSite https://www.example.com -Path \\file_server\share\site_name.bak -HostHeaderWebApplication https://server_name

This example restores a site collection backup from the backup file \\file_server\share\site_name.bak to the host-named site collection https://www.example.com on the Web application https://server_name.

Parameters

-AssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

Type:SPAssignmentCollection
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Confirm

Prompts you for confirmation before executing the command. For more information, type the following command: get-help about_commonparameters

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-ContentDatabase

Specifies the SQL Server content database where the site collection data will be stored. If no content database is specified, the content database with the greatest unused site collection capacity and whose database status is ready will be used.

Type:SPContentDatabasePipeBind
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-DatabaseName

Specifies the SQL Server content database where the site collection data will be stored. If no content database is specified, the content database with the greatest unused site collection capacity and whose database status is ready will be used.

The type must be a valid database name, in the form SQLDB1.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-DatabaseServer

Specifies the name of the SQL Server containing the content database specified by the DatabaseName parameter.

The type must be a valid database server name, in the form SQLBE1 and needs to be used in conjunction with the DatabaseName parameter.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Force

Specifies that the existing site collection at the URL location is to be overwritten by this restoration.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-GradualDelete

Specifies that the site collection being overwritten with the Force parameter should be gradually deleted over time by a timer job instead of all at once, which reduces its impact on SharePoint Products and SQL Server performance. This option is recommended for large site collections.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-HostHeaderWebApplication

A valid URL assigned to the Web application by using alternate access mapping, such as https://server_name

Restores a site collection as a host-named site collection instead of a path-based site collection. When the HostHeaderWebApplication parameter is present, the value of the Identity parameter is the URL of the host-named site collection and the value of the HostHeaderWebApplication parameter is the URL of the Web application that will hold the host-named site collection.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Identity

Specifies the URL location to which the site collection is restored.

A site collection does not have to already exist at the URL location to perform a restore. However, you must specify a valid URL location that a site collection can be created. If a site collection already exists at the specified URL location, you must specify the Force parameter to overwrite it.

The type must be a valid URL, in the form https://server_name/sites/site_name.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Path

Specifies a valid path to the location of the backup. For example, C:\Backup\site_name.bak.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-PreserveSiteID

Preserves the original Site ID instead of creating a new one.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-WhatIf

Displays a message that describes the effect of the command instead of executing the command. For more information, type the following command: get-help about_commonparameters

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition