在 SharePoint Server 中還原 Web 應用程式Restore web applications in SharePoint Server

摘要:了解如何還原 SharePoint Server 2016 和 SharePoint 2013 的 Web 應用程式。Summary: Learn how to restore a web application in SharePoint Server 2016 and SharePoint 2013.

您可使用 SharePoint 管理中心網站、Microsoft PowerShell 或 SQL Server 工具還原 SharePoint Server 的 Web 應用程式。使用的備份工具須視以下條件而定:部署的環境、備份排程需求及您與組織的服務等級協定。You can restore a web application in SharePoint Server by using the SharePoint Central Administration website, Microsoft PowerShell, or SQL Server tools. Which backup tool you use depends on what kind of environment you have deployed, what your backup schedule requires, and what service level agreements you have made with your organization.

開始之前Before you begin

還原 Web 應用程式時,也會還原 Internet Information Services (IIS) 設定,以及與 Web 應用程式相關聯的所有內容資料庫。When you restore a web application, you also restore the Internet Information Services (IIS) settings and all content databases that are associated with the web application.

開始這項作業之前,請先檢閱下列資訊,準備還原 Web 應用程式:Before you begin this operation, review the following information as you prepare to restore a web application:

  • 依照本文的程序,您一次只能還原一個 Web 應用程式。不過,您可以透過還原整個伺服器陣列的方式,同時還原伺服器陣列中的所有 Web 應用程式。You can only restore one web application at a time by using the procedures in this article. However, you can at the same time restore all the web applications in the farm by restoring the complete farm.

  • 如果 Web 應用程式使用物件快取,您必須在還原 Web 應用程式之後,手動為 Web 應用程式設定兩個特殊使用者帳戶。如需有關物件快取及如何設定這些使用者帳戶的詳細資訊,請參閱〈Configure object cache user accounts in SharePoint Server〉。If a web application uses the object cache, you must manually configure two special user accounts for the web application after you restore the web application. For more information about the object cache and how to configure these user accounts, see Configure object cache user accounts in SharePoint Server.

  • 您無法使用 SQL Server 還原 Web 應用程式。You cannot use SQL Server tools to restore a web application.

  • 若將設定為使用宣告式驗證的 Web 應用程式還原,您必須在還原 Web 應用程式後執行一些其他步驟,才能還原宣告式驗證。When you restore a web application that is configured to use claims-based authentication, there are additional steps that you must follow after restoring the web application to restore claims-based authentication.

使用 PowerShell 還原 SharePoint Server 的 Web 應用程式Using PowerShell to restore a web application in SharePoint Server

您可以使用 PowerShell 手動還原 Web 應用程式,或以指令碼的一部分之形態,安排定期執行。You can use PowerShell to restore a web application manually or as part of a script that can be run at scheduled intervals.

使用 PowerShell 還原 Web 應用程式To restore a web application 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 <BackupFolderName> -RestoreMethod Overwrite -Item  <WebApplicationName> [-BackupId <GUID>] [-Verbose]
    

    其中:Where:

    • <備份資料夾名稱> 是您用於備份檔案的完整資料夾路徑。<BackupFolderName> is the full path of the folder that you use for backup files.

    • <WebApplicationName> 是已備份之 Web 應用程式的名稱。<WebApplicationName> is the name of the web application that was backed up.

    • <GUID> 是用於執行還原作業的備份識別碼。<GUID> is the identifier of the back up to use for the restore operation.

      如果未指定 BackupID 參數的值,則會使用最近的備份。您無法使用僅限設定的備份還原 Web 應用程式。您可以輸入下列命令檢視伺服器陣列的備份:If you do not specify the value of the BackupID parameter, the most recent backup will be used. You cannot restore a web application by using a configuration-only backup. You can view the backups for the farm by typing the following:

    Get-SPBackupHistory -Directory <BackupFolderName> -ShowBackup
    

如需詳細資訊,請參閱<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 Server 的 Web 應用程式Using Central Administration to restore a web application in SharePoint Server

您可以使用 管理中心 還原 Web 應用程式。You can use Central Administration to restore a web application.

使用 管理中心 還原 Web 應用程式To restore a web application by using Central Administration

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。另請確認 SharePoint 計時器服務及伺服器陣列資料庫存取帳戶具有備份資料夾的「完全控制」權限。Verify that the user account performing this procedure is a member of the Farm Administrators group. Additionally, verify that the SharePoint Timer service and the Farm Database Access account have Full Control permissions on the backup folder.

  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: 選取要還原的備份」頁面上,從備份清單中選取包含伺服器陣列或 Web 應用程式備份的備份工作,然後按 [下一步]。只要按一下備份旁的 (+),即可檢視每項備份的詳細資訊。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.

    注意

    若正確的備份工作未出現,請在 [目前目錄位置] 文字方塊中,輸入正確備份資料夾的通用命名慣例 (UNC) 路徑,然後按一下 [重新整理]。 > 您無法使用僅限設定的備份還原 Web 應用程式。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. > You cannot use a configuration-only backup to restore the web application.

  5. 在 [從備份還原 - 步驟 3 之 2: 選取要還原的元件] 頁面上,選取 Web 應用程式旁的核取方塊,然後按 [下一步]。On the Restore from Backup — Step 2 of 3: Select Component to Restore page, select the check box that is next to the web application, and then click Next.

  6. 在從備份還原-步驟 3 之 3: 選取還原選項] 頁面的 [還原元件] 區段中,確定陣列\< Web 應用程式>出現在 [還原下列內容] 清單中。On the Restore from Backup — Step 3 of 3: Select Restore Options page, in the Restore Component section, make sure that Farm\<Web application> appears in the Restore the following content list.

    在 [僅還原組態設定] 區段中,確定已選取 [還原內容與組態設定] 選項。In the Restore Only Configuration Settings section, make sure that the Restore content and configuration settings option is selected.

    在 [還原選項] 區段的 [還原的類型] 下,選取 [相同的設定] 選項。對話方塊會隨即出現,請您確認該作業。按一下 [確定]。In the Restore Options section, under Type of Restore, select the Same configuration option. A dialog box appears that asks you to confirm the operation. Click OK.

    注意

    若未顯示 [僅還原組態設定] 區段,則您選取的備份會是僅限設定的備份。您必須選取其他備份。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. 您可以在 [備份與還原工作狀態] 頁面上方的 [整備] 區段中,檢視所有復原工作的一般狀態。在同頁面底部的 [還原] 區段中,則可檢視目前復原工作的狀態。狀態頁面每 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.

    如有收到錯誤,可以檢閱 [備份與還原工作狀態] 頁面的 [失敗訊息] 欄。也可在您指定之 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.

使用 SQL Server 工具還原與 SharePoint Server 的 Web 應用程式相關聯的資料庫Using SQL Server tools to restore databases associated with a web application in SharePoint Server

您不能使用 SQL Server 工具還原整個 Web 應用程式。不過,您可以還原與 Web 應用程式相關聯的所有資料庫。若要還原整個 Web 應用程式,請使用 PowerShell 或 管理中心。You cannot restore the complete web application by using SQL Server tools. However, you can restore all the databases that are associated with the web application. To restore the complete web application, use either PowerShell or Central Administration.

使用 SQL Server 工具還原與 Web 應用程式相關聯的資料庫To restore databases associated with a web application 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 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. 啟動 Windows SharePoint Services 計時器服務。Start the Windows SharePoint Services Timer service.

還原使用 SharePoint Server 表單型驗證之 Web 應用程式的其他步驟Additional steps to restore a web application that uses forms-based authentication in SharePoint Server

還原使用表單型驗證的 Web 應用程式之後,您必須依照這些步驟,重新設定 Web 應用程式使用表單型驗證。After you restore a web application that uses forms-based authentication, you must follow these steps to reconfigure the web application to use forms-based authentication.

  1. 重新註冊 Web.config 檔案中的成員資格及角色提供者。Re-register the membership and role providers in the Web.config file.

  2. 重新部署提供者。Redeploy the providers.

參考下列其他步驟,可在還原使用 SharePoint Server 宣告式驗證的 Web 應用程式之後,移除重複的宣告提供者Additional steps to remove duplicate claims providers after restoring a web application that uses claims-based authentication in SharePoint Server

還原設定為使用宣告式驗證的 Web 應用程式之後,通常可以看到重複或其他的宣告提供者。您必須依照下列程序移除這些重複提供者:After a web application that is configured to use claims-based authentication is restored, duplicate or additional claims providers are often visible. You must use the following process to remove the duplicate providers:

  1. 在管理中心中按一下 [管理 Web 應用程式],選取使用宣告式驗證的 Web 應用程式,然後按一下 [驗證提供者] 。In Central Administration, click Manage Web application, select a web application that uses claims-based authentication, and then click Authentication Providers.

  2. 選取與 Web 應用程式相關聯的區域開啟 [編輯驗證] 頁面,然後按一下 [儲存]。Select a zone that the web application is associated with to open the Edit Authentication page, and then click Save.

  3. 依序對每個區域及使用宣告式驗證的每個 Web 應用程式重複以上步驟。Repeat for each zone, and then for each web application that uses claims-based authentication.

重設 SharePoint Server 物件快取使用者帳戶的其他步驟Additional steps to re-configure object cache user accounts in SharePoint Server

若您設定了 Web 應用程式的物件快取使用者帳戶,還原程序將不會還原這些設定。您必須重設 Web 應用程式的設定。如需詳細資訊,請參閱〈Configure object cache user accounts in SharePoint Server〉。If you configured object cache user accounts for the web application, the restore process will not restore these settings. You must re-configure the settings for the web application. For more information, see Configure object cache user accounts in SharePoint Server.

另請參閱See also

概念Concepts

在 SharePoint Server 中備份 Web 應用程式Back up web applications in SharePoint Server

在 SharePoint Server 中規劃備份和修復Plan for backup and recovery in SharePoint Server