Previous Topic: Restore a SiteNext Topic: Restore a File


Restore a List or a Library

Follow these steps:

  1. Recover the list or library content from an unattached content database.
    1. $database = Get-SPContentDatabase -ConnectAsUnattachedDatabase -DatabaseName xxxx -DatabaseServer xxxx

      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.

    2. Setting object to export.

      $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}"

    3. Configuring Export Settings

      $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)

    4. Back up the list or library to a file.

      $ExportJob.Run()

      For more details, see the article from Microsoft.

  2. Click SharePoint Management Shell to launch the console.
  3. Use PowerShell commands to restore the list or library to the origin location or the new location.
    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.