在 SharePoint Server 中還原 Web 應用程式

適用于:yes-img-132013 yes-img-16 2016yes-img-192019 yes-img-se訂閱版本 no-img-sopMicrosoft 365 中的 SharePoint

您可使用 SharePoint 管理中心網站、Microsoft PowerShell 或 SQL Server 工具還原 SharePoint Server 的 Web 應用程式。 使用的備份工具須視以下條件而定:部署的環境、備份排程需求及您與組織的服務等級協定。

開始之前

還原 Web 應用程式時,也會還原 Internet Information Services (IIS) 設定,以及與 Web 應用程式相關聯的所有內容資料庫。

開始這項作業之前,請先檢閱下列資訊,準備還原 Web 應用程式:

  • 依照本文的程序,您一次只能還原一個 Web 應用程式。 不過,您可以透過還原整個伺服器陣列的方式,同時還原伺服器陣列中的所有 Web 應用程式。

  • 如果 Web 應用程式使用物件快取,您必須在還原 Web 應用程式之後,手動為 Web 應用程式設定兩個特殊使用者帳戶。 如需有關物件快取及如何設定這些使用者帳戶的詳細資訊,請參閱〈Configure object cache user accounts in SharePoint Server〉。

  • 您無法使用 SQL Server 還原 Web 應用程式。

  • 若將設定為使用宣告式驗證的 Web 應用程式還原,您必須在還原 Web 應用程式後執行一些其他步驟,才能還原宣告式驗證。

使用 PowerShell 還原 SharePoint Server 的 Web 應用程式

您可以使用 PowerShell 手動還原 Web 應用程式,或以指令碼的一部分之形態,安排定期執行。

使用 PowerShell 還原 Web 應用程式

  1. 確認您具備下列成員身分:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。

      系統管理員可以使用 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]
    

    其中:

    • <備份資料夾名稱> 是您用於備份檔案的完整資料夾路徑。

    • <WebApplicationName> 是已備份之 Web 應用程式的名稱。

    • <GUID> 是用於執行還原作業的備份識別碼。

    如果您未指定 參數的 BackupID 值,則會使用最新的備份。 您無法使用僅限設定的備份還原 Web 應用程式。 您可以輸入下列命令檢視伺服器陣列的備份:

    Get-SPBackupHistory -Directory <BackupFolderName> -ShowBackup
    

如需詳細資訊,請參閱<Restore-SPFarm>。

注意事項

[!附註] 建議您在執行命令列管理工作時使用 Windows PowerShell。 Stsadm 命令列工具已過時,但為與舊版產品相容,仍會隨附提供。

使用管理中心還原 SharePoint Server 的 Web 應用程式

您可以使用 管理中心 還原 Web 應用程式。

使用 管理中心 還原 Web 應用程式

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。 另請確認 SharePoint 計時器服務及伺服器陣列資料庫存取帳戶具有備份資料夾的「完全控制」權限。

  2. 啟動管理中心。

  3. 在管理中心首頁上,按一下 [備份與還原] 區段中的 [從備份還原]

  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. 在 [從備份還原 - 步驟 3 之 2: 選取要還原的元件] 頁面上,選取 Web 應用程式旁的核取方塊,然後按 [下一步]。

  6. 在 [從備份還原 — 步驟 3: 選取還原選項] 頁面的 [還原元件] 區段中,確定 [還原下列內容] 清單中顯示Farm\ < 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.

    按一下 [開始還原]。

  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. 在 [物件總管] 中,展開 [資料庫]。

  5. 以滑鼠右鍵按一下要還原的資料庫,並依序指向 [工作] 及 [還原],然後按一下 [資料庫]。

    資料庫在復原作業期間會自動離線,且無法供其他程序存取。

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

  • 如果您已包含所有必須還原的交易記錄檔,請選取 [RECOVER WITH RECOVERY]。

  • 如果您必須還原其他交易記錄檔,請選取 [RECOVER WITH NORECOVERY]。

  • 此案例不會使用第三個選項 [RECOVER WITH STANDBY]

    注意事項

    如需復原選項的詳細資訊,請參閱<還原資料庫 (選項頁面)>。

  1. 按一下 [確定] 完成復原作業。

  2. 對要還原的每個資料庫重複步驟 4 到 10。

  3. 啟動 Windows SharePoint Services 計時器服務。

還原使用 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 中規劃備份和修復