Follow these steps:
Example: The name of list/library to be restored is NewList1 and the URL is /TestSite1/NewList1.
The list or library is exported to a file.
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]::List
$ExportObject.Url = $ListUrl
$ListUrl: Specifies the URL location to which the list or library is backed up. If it is a list, use the parameter "/Lists/{ListName}". If it is a library, use the parameter "/{LibraryName}"
$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)
$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\list.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 will not be added.
The default value is Add.
For more details, see the article from Microsoft.
Copyright © 2016 |
|