Follow these steps:
Example: The name of site to be restored is TestSite1 and the URL is /TestSite1/.
Click SharePoint Management Shell to launch the console.
ConnectAsUnattachedDatabase: Specifies that only unattached databases in the farm are returned.
DatabaseName: Specifies the name of the content database.
DatabaseServer: Specifies the name of the host server for the content database specified in the DatabaseName parameter.
For more details, see the article from Microsoft.
$ExportObject = New-Object Microsoft.SharePoint.Deployment.SPExportObject
$ExportObject.Type = [Microsoft.SharePoint.Deployment.SPDeploymentObjectType]::Web
$ExportObject.Url = $SiteUrl
$SiteUrl: Specifies the URL location to which the site will be backed up.
$ExportSettings = New-Object Microsoft.SharePoint.Deployment.SPExportSettings
$ExportSettings.UnattachedContentDatabase = $database
$ExportSettings.SiteUrl = $CAUrl
$CAUrl: Specifies Central Administration Site Url.
$ExportSettings.FileLocation = $ExportPath
$ExportSettings.LogFilePath = $ExportPath
$ExportPath: Specifies the path to save the backup file (for example, C:\backup).
$ExportSettings.BaseFileName = $ExportFile
$ExportFile: Specifies the filename of the backup file (for example, site.cmp).
$ExportSettings.IncludeVersions = [Microsoft.SharePoint.Deployment.SPIncludeVersions]::All
$ExportSettings.ExportMethod = [Microsoft.SharePoint.Deployment.SPExportMethodType]::ExportAll
$ExportSettings.IncludeVersions = [Microsoft.SharePoint.Deployment.SPIncludeVersions]::All
$ExportSettings.ExportObjects.Add($ExportObject)
$ExportSettings.Validate()
$ExportJob = New-Object Microsoft.SharePoint.Deployment.SPExport($ExportSettings)
Back up the site to a file.
$ExportJob.Run()
For more details, see the article from Microsoft.
Import-SPWeb -Identity xxxx -Path xxxx -IncludeUserSecurity:$true -UpdateVersions:xxxx
Identity: Specifies the URL or GUID of the Web to import into. for example, http://www.contoso.com.
Path: Specifies the name of the import file. for example, C:\backup\site.cmp’
IncludeUserSecurity: Preserves the user security settings except for SPLists that have broken inheritance and item level permissions set.
UpdateVersions: Indicates how to resolve situations where a file version to be imported to a site already exists in that site. You can select one of the following options:
Add: Adds the file as a new version.
Overwrite: Overwrites the current file and all of its versions (delete then insert).
Ignore: Ignores the file if it exists on the destination. The new file is not added.
The default value is Add.
For more details, see the article from Microsoft.
Copyright © 2016 |
|