在 SharePoint Server 中還原內容資料庫Restore content databases in SharePoint Server

摘要: 了解如何在 SharePoint Server 2016 和 SharePoint 2013 中還原內容資料庫。Summary: Learn how to restore a content database in SharePoint Server 2016 and SharePoint 2013.

您可以在 SharePoint Server 中使用 SharePoint 管理中心網站、PowerShell 或 SQL Server 工具來還原內容資料庫。所使用的還原工具會視已部署的環境類型、排程需求以及與組織建立的服務等級協定而定。You can restore a content database in SharePoint Server by using the SharePoint Central Administration website, PowerShell, or SQL Server tools. The restore tool that you use depends on the kind of environment that you have deployed, your schedule requirements, and service level agreements that you have made with your organization.

開始之前Before you begin

您可以透過一次還原一個內容資料庫的方式,還原任何內容資料庫或數個內容資料庫。如需如何同時備份伺服器陣列中所有內容資料庫的資訊,請參閱<在 SharePoint Server 中備份伺服器陣列>。You can restore any content database or several content databases, one at a time. For information about how to back up all the content databases in a farm at the same time, see Back up farms in SharePoint Server.

開始這項作業之前,請先檢閱下列如何還原內容資料庫的相關資訊:Before you begin this operation, review the following information about how to restore a content database:

  • SharePoint Server 會還原遠端二進位大型物件 (BLOB) 存放區,但只有在您使用 SQL Filestream 遠端 BLOB 存放區提供者將資料置於遠端 BLOB 存放區時。SharePoint Server restores remote Binary Large Objects (BLOB) stores but only if you are using the SQL Filestream remote BLOB store provider to place data in remote BLOB stores.

    如果您使用其他提供者,則必須手動還原這些遠端 BLOB 存放區。If you are using another provider you must manually restore these remote BLOB stores.

使用PowerShell還原 SharePoint 內容資料庫Using PowerShell to restore a SharePoint content database

您可以使用 PowerShell 還原內容資料庫。You can use PowerShell to restore a content database.

使用 PowerShell 還原內容資料庫To restore a content database by using PowerShell

  1. 確認您具備下列成員身分:Verify that you have the following memberships:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。securityadmin fixed server role on the SQL Server instance.

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。db_owner fixed database role on all databases that are to be updated.

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。Administrators group on the server on which you are running the PowerShell cmdlets.

      系統管理員可以使用 Add-SPShellAdmin Cmdlet 授與使用 SharePoint Server Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server cmdlets.

      注意

      如果您不具備上述權限,請連絡安裝程式系統管理員或 SQL Server 系統管理員要求權限。如需 PowerShell 權限的其他資訊,請參閱 Add-SPShellAdminIf you do not have permissions, contact your Setup administrator or SQL Server administrator to request permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.

  2. 啟動 SharePoint 管理命令介面。Start the SharePoint Management Shell.

  3. 在 PowerShell 命令提示字元中,輸入下列命令:At the PowerShell command prompt, type the following command:

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

    其中:Where:

    • <備份資料夾> 是備份服務應用程式的備份資料夾名稱和路徑。<BackupFolder> is the name and path for the backup folder where the service application was backed up.

    • <ContentDatabase> 是內容資料庫的名稱。<ContentDatabase> is the name of the content database.

      若您不使用 BackupId 參數,則會使用最近的備份。若要檢視伺服器陣列的所有備份,請在 PowerShell 命令提示字元處輸入下列命令:If you do not use the BackupId parameter, the most recent backup will be used. To view all of the backups for the farm, type the following command at the PowerShell command prompt:

    Get-SPBackupHistory -Directory <Backup folder>
    

如需詳細資訊,請參閱<Restore-SPFarm>。For more information, see Restore-SPFarm.

注意

建議您在執行命令列管理工作時使用 Windows PowerShell。Stsadm 命令列工具已過時,但為與舊版產品相容,仍會隨附提供。We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.

使用管理中心還原 SharePoint 內容資料庫Using Central Administration to restore a SharePoint content database

您可以使用管理中心還原伺服器陣列或伺服器陣列的元件。You can use Central Administration to restore a farm or components of a farm.

若要使用管理中心還原內容資料庫To restore a content database by using Central Administration

  1. 確認執行此程序的使用者帳戶為 SharePoint 伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators SharePoint group.

  2. 啟動管理中心。Start Central Administration.

  3. 在管理中心首頁上,按一下 [備份與還原]**** 區段中的 [從備份還原]*In Central Administration, on the home page, in the *Backup and Restore section, click Restore from a backup.

  4. 在 [從備份還原 - 步驟 3 之 1:選取要還原的備份] 頁面上,從備份清單中選取含有內容資料庫備份的備份工作,然後按 [下一步]*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 content database backup, and then click *Next.

    注意

    如果正確的備份工作未出現,請在 [目前目錄位置]**** 文字方塊中輸入正確備份資料夾的路徑,然後按一下 [重新整理]*If the correct backup job does not appear, in the *Current Directory Location text box, enter the path of the correct backup folder, and then click Refresh.

  5. 在 [從備份還原 - 步驟 3 之 2:選取要還原的元件] 頁面上,選取內容資料庫旁的核取方塊,然後按 [下一步]*On the Restore from Backup — Step 2 of 3: Select Component to Restore page, select the check box that is next to the content database, and then click *Next.

    注意

    如果無法選取內容資料庫,則必須使用 PowerShell 或 SQL Server 工具還原內容資料庫。If the content database is not selectable, you must use PowerShell or SQL Server tools to restore the content database.

  6. 在 [從備份還原 - 步驟 3 之 3:選取還原選項] 頁面上,於 [還原選項]**** 區段的 [還原的類型]**** 下,按一下 [相同的設定]**** 選項。對話方塊會隨即出現,請您確認該作業。請按一下 [確定]*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. A dialog box appears that asks you to confirm the operation. Click OK.

    按一下 [開始還原]*Click *Start Restore.

  7. 您可以在 [備份與還原工作狀態] 頁面上方的 [整備] 區段中,檢視所有復原工作的一般狀態。在同頁面底部的 [還原] 區段中,則可檢視目前復原工作的狀態。狀態頁面每 30 秒會自動更新。只要按一下 [重新整理],即可手動更新狀態詳細資料。備份與復原都是計時器服務工作。因此,數秒之後才會開始復原。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.

    如有收到錯誤,可以檢閱 [備份與還原工作狀態] 頁面的 [失敗訊息] 欄。您也可以在步驟 2 中所指定之 UNC 路徑下的 Sprestore.log 檔案中查看詳細資訊。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 內容資料庫Using SQL Server tools to restore a SharePoint content database

您可以遵循下列步驟,使用 SQL Server 工具還原內容資料庫:You can use SQL Server tools to restore a content database by following these steps:

  1. 請儘可能備份內容資料庫的即時交易記錄檔,以保護自從上次完整備份後所進行的任何變更。If possible, back up the live transaction log of the content database to protect any changes that were made after the last full backup.

  2. 還原上次的完整資料庫備份。Restore the last full database backup.

  3. 還原在最近的完整資料庫備份之後,所進行的最近之差異資料庫備份。Restore the most recent differential database backup that occurred after the most recent full database backup.

  4. 還原在最近的完整或差異資料庫備份之後,所進行的所有交易記錄檔備份。Restore all transaction log backups that occurred after the most recent full or differential database backup.

若要使用 SQL Server 工具還原內容資料庫To restore a content database by using SQL Server tools

  1. 確認執行此程序的使用者帳戶是 sysadmin 固定伺服器角色的成員。Verify that the user account performing this procedure is a member of the sysadmin fixed server role.

  2. 如果 SharePoint 計時器服務正在執行,請停止該服務並等候幾分鐘,直到所有目前執行中的預存程序完成為止。還原內容資料庫之後,請不要重新啟動該服務。If the SharePoint Timer service is running, stop the service and wait for several minutes for any currently running stored procedures to finish. Do not restart the service until after you restore the content databases.

  3. 啟動 SQL Server Management Studio 並連線至資料庫伺服器。Start SQL Server Management Studio and connect to the database server.

  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.

    資料庫在復原作業期間會自動離線,且無法供其他程序存取。The database is automatically taken offline during the recovery operation and cannot be accessed by other processes.

  6. 在 [還原資料庫] 對話方塊中指定目的地與來源,然後選取要還原的一或多個備份組。In the Restore Database dialog box, specify the destination and the source, and then select the backup set or sets that you want to restore.

    目的地與來源的預設值適合大部分的復原案例。The default values for destination and source are appropriate for most recovery scenarios.

  7. 在 [選取頁面] 窗格中,按一下 [選項]。In the Select a page pane, click Options.

  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. 在 [復原狀態] 區段中:In the Recovery state section:

    • 如果您已包含所有必須還原的交易記錄檔,請選取 [RECOVER WITH RECOVERY]。If you have included all the transaction logs that you must restore, select RECOVER WITH RECOVERY.

    • 如果您必須還原其他交易記錄檔,請選取 [RECOVER WITH NORECOVERY]。If you must restore additional transaction logs, select RECOVER WITH NORECOVERY.

    • 此案例不會使用第三個選項 [RECOVER WITH STANDBY]*The third option, *RECOVER WITH STANDBY is not used in this scenario.

      注意

      如需復原選項的詳細資訊,請參閱<還原資料庫 (選項頁面)>。For more information about these recovery options, see Restore Database (Options Page).

  10. 按一下 [確定]**** 完成復原作業。Click OK to complete the recovery operation.

  11. 對要還原的每個資料庫重複步驟 4 到 10。Repeat steps 4 through 10 for each database that you are restoring.

  12. 啟動 SharePoint Timer Service。Start the SharePoint Timer service.

另請參閱See also

概念Concepts

在 SharePoint Server 中備份內容資料庫Back up content databases in SharePoint Server