Restore a Site

Follow these steps:

  1. Recover site content from an unattached content database.
  2. Use Central Administration

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

    4. Select the options for security and versions (by default All Versions).
    5. Click the Start Export button to begin the export, then the site 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.
    3. DatabaseName: Specifies the name of the content database.
    4. DatabaseServer: Specifies the name of the host server for the content database specified in the DatabaseName parameter.
    5. For more details, see the article from Microsoft.
    6. Setting object to export
    7. $ExportObject = New-Object Microsoft.SharePoint.Deployment.SPExportObject
    8. $ExportObject.Type = [Microsoft.SharePoint.Deployment.SPDeploymentObjectType]::Web
    9. $ExportObject.Url = $SiteUrl
    10. $SiteUrl: Specifies the URL location to which the site will be backed up.
    11. Configuring Export Settings
    12. $ExportSettings = New-Object Microsoft.SharePoint.Deployment.SPExportSettings
    13. $ExportSettings.UnattachedContentDatabase = $database
    14. $ExportSettings.SiteUrl = $CAUrl
    15. $CAUrl: Specifies Central Administration Site Url.
    16. $ExportSettings.FileLocation = $ExportPath
    17. $ExportSettings.LogFilePath = $ExportPath
    18. $ExportPath: Specifies the path to save the backup file (for example, C:\backup).
    19. $ExportSettings.BaseFileName = $ExportFile
    20. $ExportFile: Specifies the filename of the backup file (for example, site.cmp).
    21. $ExportSettings.IncludeVersions = [Microsoft.SharePoint.Deployment.SPIncludeVersions]::All
    22. $ExportSettings.ExportMethod = [Microsoft.SharePoint.Deployment.SPExportMethodType]::ExportAll
    23. $ExportSettings.IncludeVersions = [Microsoft.SharePoint.Deployment.SPIncludeVersions]::All
    24. $ExportSettings.ExportObjects.Add($ExportObject)
    25. $ExportSettings.Validate()
    26. $ExportJob = New-Object Microsoft.SharePoint.Deployment.SPExport($ExportSettings)
    27. Back up the site to a file.
    28. $ExportJob.Run()
    29. For more details, see the article from Microsoft.
  3. Click SharePoint Management Shell to launch the console.
  4. Use PowerShell commands to restore the site 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\site.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.

    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.

  11. For more details, see the article from Microsoft.