Restore a List or a Library

Follow these steps:

  1. Recover the list or library content from an unattached content database.
  2. Use Central Administration

    1. Select the export site or list option, and click Next.
    2. Select the site and the list and provide the file location for the export package.
    3. Example: The name of list/library to be restored is NewList1 and the URL is /TestSite1/NewList1.

    4. Select options for security and versions (by default All Versions).
    5. Click Start Export to begin the export.
    6. The list or library is exported to a file.

    Use PowerShell commands

    1. $database = Get-SPContentDatabase -ConnectAsUnattachedDatabase -DatabaseName xxxx -DatabaseServer xxxx
    2. 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.

    3. Setting object to export.
    4. $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}"

    5. Configuring Export Settings
    6. $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)

    7. Back up the list or library to a file.
    8. $ExportJob.Run()

      For more details, see the article from Microsoft.

  3. Click SharePoint Management Shell to launch the console.
  4. Use PowerShell commands to restore the list or library to the origin location or the new location.
  5. Import-SPWeb -Identity xxxx -Path xxxx -IncludeUserSecurity:$true -UpdateVersions:xxxx

  6. Identity: Specifies the URL or GUID of the Web to import into. For example, http://www.contoso.com
  7. Path: Specifies the name of the import file. For example, C:\backup\list.cmp’
  8. IncludeUserSecurity: Preserves the user security settings except for SPLists that have broken inheritance and item level permissions set.
  9. 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:
  10. Add: Adds the file as a new version.
  11. Overwrite: Overwrites the current file and all of its versions (delete then insert)
  12. Ignore: Ignores the file if it exists on the destination. The new file will not be added.
  13. The default value is Add.
  14. For more details, see the article from Microsoft.