在 SharePoint Server 中还原 Web 应用程序

适用于:yes-img-132013 yes-img-162016 yes-img-192019 yes-img-seSubscription Edition no-img-sopSharePoint in Microsoft 365

您可以使用 SharePoint 管理中心网站、Microsoft PowerShell 或 SQL Server 工具还原 SharePoint Server 中的 Web 应用程序。 您使用哪一种备份工具取决于您已部署的环境的类别、您的备份计划所需的内容以及您与您的组织之间签订的服务级别协议。

开始之前

在还原 Web 应用程序时,还会还原与此 Web 应用程序关联的 Internet Information Services (IIS) 设置和所有内容数据库。

开始此操作之前,在准备还原 Web 应用程序时请查看以下信息:

  • 使用本文中的过程一次只能还原一个 Web 应用程序。 但是,通过还原完整服务器场,可以同时还原服务器场中的所有 Web 应用程序。

  • 如果 Web 应用程序使用对象缓存,则必须在还原此 Web 应用程序后为其手动配置两个特殊用户帐户。 有关对象缓存和如何配置这些用户帐户的详细信息,请参阅Configure object cache user accounts in SharePoint Server

  • 无法使用 SQL Server 工具来还原 Web 应用程序。

  • 在还原配置为使用基于声明的身份验证的 Web 应用程序时,必须在还原此 Web 应用程序后执行其他一些步骤才能还原基于声明的身份验证。

使用 PowerShell 还原 SharePoint Server 中的 Web 应用程序

可以使用 PowerShell 手动还原 Web 应用程序,也可以使用按计划间隔运行的脚本来还原 Web 应用程序。

使用 PowerShell 还原 Web 应用程序的具体步骤

  1. 确认您具有以下成员身份:

    • SQL Server 实例上的 securityadmin 固定服务器角色。

    • 要更新的所有数据库上的 db_owner 固定数据库角色。

    • 运行 PowerShell cmdlet 的服务器上的 Administrators 组。

      管理员可以使用 Add-SPShellAdmin cmdlet 授予使用 SharePoint Server cmdlet 的权限。

    注意

    [!注意] 如果您不具有这些权限,请联系您的安装管理员或 SQL Server 管理员来请求权限。 有关 PowerShell 权限的其他信息,请参阅 Add-SPShellAdmin

  2. 启动 SharePoint 命令行管理程序。

  3. 在 PowerShell 命令提示符处,键入以下命令:

    Restore-SPFarm -Directory <BackupFolderName> -RestoreMethod Overwrite -Item  <WebApplicationName> [-BackupId <GUID>] [-Verbose]
    

    其中:

    • <BackupFolderName> 是用于备份文件的文件夹的完整路径。

    • <WebApplicationName> 是已备份的 Web 应用程序的名称。

    • <GUID> 是用于执行还原操作的备份的标识符。

    如果未指定 参数的值 BackupID ,将使用最新的备份。 无法使用纯配置备份来还原 Web 应用程序。 可以通过键入以下信息来查看服务器场备份:

    Get-SPBackupHistory -Directory <BackupFolderName> -ShowBackup
    

有关详细信息,请参阅 Restore-SPFarm

注意

[!注意] 我们建议您在执行命令行管理任务时使用 Windows PowerShell。 Stsadm 命令行工具已被弃用,仍然包含该工具是为了支持与之前产品版本的兼容性。

使用管理中心还原 SharePoint Server 中的 Web 应用程序

您可以使用管理中心来还原 Web 应用程序。

使用管理中心还原 Web 应用程序的具体步骤

  1. 确认执行此过程的用户帐户是服务器场管理员组的成员。 另外确认 SharePoint 定时服务和服务器场数据库访问帐户拥有对备份文件夹的完全控制权限。

  2. 启动管理中心。

  3. In Central Administration, on the home page, in the Backup and Restore section, click Restore from a backup.

  4. On the Restore from Backup — Step 1 of 3: Select Backup to Restore page, from the list of backups, select the backup job that contains the farm or web application backup, and then click Next. You can view more details about each backup by clicking the (+) next to the backup.

    注意

    If the correct backup job does not appear, in the Current Directory Location text box, type the Universal Naming Convention (UNC) path of the correct backup folder, and then click Refresh. > 不能使用仅配置备份来还原 Web 应用程序。

  5. 在"从备份还原 - 第 2 步(共 3 步): 选择要还原的组件"页上,选中 Web 应用程序旁边的复选框,然后单击"下一步"。

  6. 在“从备份还原 - 步骤 3(共 3 步:选择还原选项)”页上的“ 还原组件 ”部分中,确保 “服务器场\<Web 应用程序> ”显示在 “还原以下内容” 列表中。

    在“仅还原配置设置”部分,确保选中了“还原内容和配置设置”选项。

    In the Restore Options section, under Type of Restore, select the Same configuration option. 此时会显示一个对话框,要求你确认操作。 单击“确定”。

    注意

    If the Restore Only Configuration Settings section does not appear, the backup that you selected is a configuration-only backup. You must select another backup.

    Click Start Restore.

  7. You can view the general status of all recovery jobs at the top of the Backup and Restore Job Status page in the Readiness section. You can view the status for the current recovery job in the lower part of the page in the Restore section. The status page updates every 30 seconds automatically. You can manually update the status details by clicking Refresh. Backup and recovery are Timer service jobs. Therefore, it may take several seconds for the recovery to start.

    If you receive any errors, you can review them in the Failure Message column of the Backup and Restore Job Status page. You can also find more details in the Sprestore.log file at the UNC path that you specified.

使用 SQL Server 工具还原与 SharePoint Server 中的 Web 应用程序关联的数据库

不能使用 SQL Server 工具来还原整个 Web 应用程序。 不过,您可以还原与该 Web 应用程序关联的所有数据库。 若要还原整个 Web 应用程序,请使用 PowerShell 或管理中心。

使用 SQL Server 工具还原与 Web 应用程序关联的数据库

  1. 确认执行此过程的用户帐户是 sysadmin 固定服务器角色的成员。

  2. 如果 SharePoint 定时服务正在运行,请停止该服务并等待几分钟,直到任何当前正在运行的存储过程完成。 在还原数据库之前,请勿重启此服务。

  3. 启动 SQL Server Management Studio 并连接到数据库服务器。

  4. In Object Explorer, expand Databases.

  5. Right-click the database that you want to restore, point to Tasks, point to Restore, and then click Database.

    在恢复操作过程中,数据库将自动脱机,任何其他进程均无法访问。

  6. 在“ 还原数据库 ”对话框中,指定目标和源,然后选择要还原的备份集或备份集。

    目标和源的默认值适用于大多数恢复方案。

  7. 在"选择页面"窗格中,单击"选项"。

  8. In the Restore options section, select only Overwrite the existing database. Unless the environment or policies require otherwise, do not select the other options in this section.

  9. 在"恢复状态"部分:

  • 如果已包括所有必须还原的事务日志,则选择"全部恢复"。

  • 如果必须还原其他事务日志,则选择"部分恢复"。

  • 在该方案中,不使用第三个选项"包含备用内容的恢复"。

    注意

    [!注意] 若要详细了解这些恢复选项,请参阅还原数据库("选项"页)

  1. 单击"确定"完成恢复操作。

  2. 针对正在还原的每个数据库重复步骤 4-10。

  3. 启动 Windows SharePoint Services Timer 服务。

还原 SharePoint Server 中使用基于表单的身份验证的 Web 应用程序的额外步骤

在还原使用基于表单的身份验证的 Web 应用程序后,必须按照以下步骤操作才能将此 Web 应用程序重新配置为使用基于表单的身份验证。

  1. 在 Web.config 文件中重新注册成员身份和角色提供程序。

  2. 重新部署这些提供程序。

还原 SharePoint Server 中使用基于声明的身份验证的 Web 应用程序后移除重复声明提供程序的额外步骤

在还原配置为使用基于声明的身份验证的 Web 应用程序后,通常会显示重复或额外的声明提供程序。 必须使用以下过程移除这些重复提供程序:

  1. 在管理中心中,单击"管理 Web 应用程序",选择使用基于表单的身份验证的 Web 应用程序,然后单击"验证提供程序"。

  2. 选择与 Web 应用程序关联的区域以打开"编辑验证"页,然后单击"保存"。

  3. 对每个区域重复此操作,然后对使用基于声明的身份验证的每个 Web 应用程序重复此操作。

在 SharePoint Server 中重新配置对象缓存用户帐户的额外步骤

如果为 Web 应用程序配置了对象缓存用户帐户,还原过程将不会还原这些设置。 您必须重新为 Web 应用程序重新配置这些设置。 有关详细信息,请参阅Configure object cache user accounts in SharePoint Server

另请参阅

概念

在 SharePoint Server 中备份 Web 应用程序

在 SharePoint Server 中规划备份和恢复