在 SharePoint Server 中还原内容数据库

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

可以使用 SharePoint 管理中心网站、PowerShell 或 SQL Server 工具在 SharePoint Server 中还原内容数据库。 您使用的还原工具取决于已部署的环境类型、您的计划要求以及您与组织达成的服务级别协议。

开始之前

可采用一次一个的方式还原任何内容数据库或若干个内容数据库。 有关如何同时备份服务器场中所有内容数据库的信息,请参阅在 SharePoint Server 中备份服务器场

在开始此操作前,请查看以下有关如何还原内容数据库的信息:

  • 只有在使用 SQL Filestream 远程 BLOB 存储提供程序将数据放入远程 BLOB 存储区时,SharePoint Server 才会还原远程二进制大型对象 (BLOB) 存储区。

    如果使用的是其他提供程序,您必须手动还原这些远程 BLOB 存储区。

使用PowerShell还原 SharePoint 内容数据库

可以使用 PowerShell 来还原内容数据库。

使用 PowerShell 还原内容数据库

  1. 确认你具有以下成员身份:
  • SQL Server 实例上的 securityadmin 固定服务器角色。

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

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

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

    注意

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

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

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

    Restore-SPFarm -Directory <BackupFolder> -RestoreMethod Overwrite -Item <ContentDatabase> [-BackupId <GUID>] [-Verbose]
    

    其中:

    • <BackupFolder> 是在其中备份服务应用程序的备份文件夹的名称和路径。

    • <ContentDatabase> 是内容数据库的名称。

    如果不使用 BackupId 参数,将使用最新的备份。 若要查看服务器场的所有备份,请在 PowerShell 命令提示符处键入以下命令:

Get-SPBackupHistory -Directory <Backup folder>

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

注意

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

使用管理中心还原 SharePoint 内容数据库

您可以使用管理中心来还原服务器场或服务器场的组件。

使用管理中心还原内容数据库

  1. 确认执行此过程的用户帐户是 SharePoint 组“服务器场管理员”的成员。

  2. 启动管理中心。

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

  4. 在"从备份还原 - 第 1 步(共 3 步): 选择要还原的备份"页上,从备份列表中选择包含内容数据库备份的备份作业,然后单击"下一步"。

    注意

    如果未显示正确的备份作业,请在"当前目录位置"文本框中输入正确备份文件夹的路径,然后单击"刷新"。

  5. 在"从备份还原 - 第 2 步(共 3 步): 选择要还原的组件"页上,选中内容数据库旁边的复选框,然后单击"下一步"。

    注意

    如果内容数据库不可选,则必须使用 PowerShell 或 SQL Server 工具还原内容数据库。

  6. On the Restore from Backup — Step 3 of 3: Select Restore Options page, in the Restore Options section, under Type of Restore, click the Same configuration option. 此时会显示一个对话框,要求你确认操作。 单击“确定”。

    单击“开始还原”。

  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 in step 2.

使用 SQL Server 工具还原 SharePoint 内容数据库

可以按以下步骤使用 SQL Server 工具还原内容数据库:

  1. 如果可能,请备份内容数据库的实时事务日志,以保护自上次完整备份以来所做的任何更改。

  2. 还原上一个完整数据库备份。

  3. 还原最近一次完整数据库备份后进行的最新差异数据库备份。

  4. 还原最近一次完整或差异数据库备份后进行的所有事务日志备份。

使用 SQL Server 工具还原内容数据库

  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. 在"恢复状态"部分:

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

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

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

    注意

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

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

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

  12. 启动 SharePoint 计时服务。

另请参阅

概念

在 SharePoint Server 中备份内容数据库