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

摘要:了解如何使用 管理中心 或 Microsoft PowerShell 備份 SharePoint Server 2016 和 SharePoint 2013 中的 Web 應用程式。Summary: Learn how to back up a web application in SharePoint Server 2016 and SharePoint 2013 by using Central Administration or Microsoft PowerShell.

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

開始之前Before you begin

本文說明如何備份 Web 應用程式。定期備份 Web 應用程式,可減少因硬體故障、停電或其他問題而發生資料遺失的機率。雖然這只是簡單的處理程序,但有助於確保所有 Web 應用程式相關資料及設定,可於必要時用於復原。建議除了定期在伺服器陣列層級備份之外,還需要建立 Web 應用程式備份。Regularly backing up a web application reduces the possibility of data losses that might occur from hardware failures, power outages, or other problems. It is a simple process that can help make sure that all the web application-related data and configurations are available for recovery, if that is required. We recommend that web application backups be created in addition to regular backups at the farm level.

開始這項作業之前,請先檢閱下列資訊:Before you begin this operation, review the following information:

  • 在您開始之前,必須建立儲存備份的網路資料夾。SharePoint 計時器服務 (SPTimerV4) 服務帳戶及伺服器陣列使用者帳戶,都必須要有此資料夾的「完全控制」權限。如需如何建立備份資料夾的詳細資訊,請參閱在 SharePoint Server 中準備備份及還原伺服器陣列Before you begin, you must create a network folder in which to store the backups. Both the SharePoint Timer Service (SPTimerV4) service account and the server farm user account must have Full Control permissions to this folder. For more information about how to create a backup folder, see Prepare to back up and restore farms in SharePoint Server.

  • 您一次只能使用本文中的程序備份一個 Web 應用程式。若要同時備份所有 Web 應用程式,您可以備份整個伺服器陣列。You can back up only one web application at a time by using the procedures in this article. You can back up all web applications by backing up the complete farm.

  • 備份 Web 應用程式不會影響伺服器陣列的狀態。但這需要資源,而且可能會在執行備份時略微影響伺服器陣列的效能。在伺服器陣列使用率最低 (如下班時間) 的期間備份 Web 應用程式,可以避免效能問題。Backing up a web application does not affect the state of the farm. However, it does require resources and might slightly affect farm performance when the backup is running. You can avoid performance issues by backing up the web application during hours when farm use is lowest, such as outside office hours.

  • 如果 Web 應用程式使用物件快取,您必須在還原 Web 應用程式之後,手動為 Web 應用程式設定兩個特殊使用者帳戶。If the web application uses the object cache, you must manually configure two special user accounts for the web application after you restore the web application.

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

  • 在備份設定為使用表單型驗證的 Web 應用程式時,您還必須使用檔案備份系統保護 Web.config 檔案,因為 Web.config 檔案已手動更新並註冊成員資格及角色提供者,且不會備份 Web.config 檔案的手動變更。同樣地,當您還原 Web 應用程式時,不會還原 Web.config 檔案。 復原後,您必須更新 Web.config 檔案並重新部署提供者。如需詳細資訊,請參閱在 SharePoint Server 中規劃使用者驗證方法When you back up a web application that is configured to use forms-based authentication, you must also use a file backup system to protect the Web.config files because the Web.config files were updated manually to register the membership and role providers, and manual changes to the Web.config files are not backed up. Similarly, Web.config files are not restored when you restore a Web application. After recovery, you must update the Web.config files and redeploy the providers. For more information, see Plan for user authentication methods in SharePoint Server.

使用 PowerShell 備份 Web 應用程式Use PowerShell to back up a web application

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

使用 PowerShell 來備份 Web 應用程式To back up 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.

      注意

      [!附註] 或者,若您不想指派 db_owner 角色的完整權限,使用者也可以是所有待更新資料庫的 db_backupoperator 固定資料庫角色成員。Alternately, the user can be a member of the db_backupoperator fixed database role on all databases that are to be updated if you do not want to assign full rights of the db_owner role.

    • 正在執行 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:

    Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} -Item <WebApplicationName> [-Verbose]
    

    其中:Where:

    • <BackupFolder> 是您用於儲存備份檔案的資料夾路徑。<BackupFolder> is the path of the folder that you use for storing backup files.

    • <WebApplicationName> 是服務應用程式的名稱。如果要顯示服務應用程式的名稱,請在 PowerShell 命令提示字元處,輸入下列命令: Backup-SPFarm -ShowTree<WebApplicationName> is the name of the web application. To display the name of the web application, at the PowerShell command prompt, type the following command: Backup-SPFarm -ShowTree

      注意

      [!附註] 若是第一次備份 Web 應用程式,必須使用 Full 選項。您必須先執行完整備份,才可執行差異備份。If you are backing up the web application for the first time, you must use the Full option. You must perform a full backup before you can perform a differential backup.

如需詳細資訊,請參閱<Backup-SPFarm.>。For more information, see Backup-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.

使用管理中心備份 Web 應用程式Use Central Administration to back up a web application

您可以使用管理中心備份 Web 應用程式。You can use Central Administration to back up a web application.

使用 管理中心 來備份 Web 應用程式To back up a web application by using Central Administration

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

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

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

  4. 在 [執行備份-步驟 2 之 1: 選取要備份] 頁面的元件從的元件] 清單中選取的 web 應用程式並再按 [下一步On the Perform a Backup — Step 1 of 2: Select Component to Back Up page, select the web application from the list of components, and then click Next.

    注意

    [!附註] Web 應用程式可能包含數個元件。您必須選取頂層元件。The web application might consist of several components. You must select the top-level component.

  5. 在 [開始備份-步驟 2 之 2: 選取備份選項] 頁面上,在 [備份類型] 區段中選取 [完整] 或 [差異On the Start Backup — Step 2 of 2: Select Backup Options page, in the Backup Type section, select either Full or Differential.

    注意

    如果您要備份 web 應用程式第一次,您必須使用 [完整] 選項。您必須執行一次完整備份才能執行差異備份。If you are backing up the web application for the first time, you must use the Full option. You must perform a full backup before you can perform a differential backup.

  6. 在 [僅備份組態設定] 區段中,按一下 [備份內容與組態設定In the Back Up Only Configuration Settings section, click Back up content and configuration settings.

  7. 在 [備份檔案位置] 區段中,輸入備份資料夾的通用命名慣例 (UNC) 路徑,然後按一下 [開始備份]。In the Backup File Location section, type the Universal Naming Convention (UNC) path of the backup folder, and then click Start Backup.

  8. 您可以在 [備份與還原工作狀態] 頁面上方的 [整備] 區段中,檢視所有備份工作的一般狀態。在同頁面底部的 [備份] 區段中,則可檢視目前備份工作的狀態。狀態頁面每 30 秒會自動更新。只要按一下 [重新整理],即可手動更新狀態詳細資料。備份與復原都是計時器服務工作。因此,數秒之後才會開始備份。You can view the general status of all backup jobs at the top of the Backup and Restore Job Status page in the Readiness section. You can view the status for the current backup job in the lower part of the page in the Backup 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 backup to start.

    若收到任何錯誤,可以檢閱 [備份與還原工作狀態] 頁面上的 [失敗訊息] 欄中。您也可以在您在步驟 6 中指定的 UNC 路徑的 Spbackup.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 Spbackup.log file at the UNC path that you specified in step 6.

使用 SQL Server 工具來備份與 Web 應用程式相關聯的資料庫Use SQL Server tools to back up a databases that are associated with a web application

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

使用 SQL Server 工具來備份與 Web 應用程式相關聯的資料庫To back up a database associated with a web application by using SQL Server tools

  1. 確認執行此程序的使用者帳戶是要備份之所有資料庫上的 SQL Server db_owner 固定資料庫角色成員。Verify that the user account that is performing this procedure is a member of the SQL Server db_owner fixed database role on all databases that are to be backed up.

  2. 開啟 SQL Server Management Studio 並連線至正確的 SQL Server 資料庫引擎執行個體。Open SQL Server Management Studio and connect to the correct instance of the SQL Server Database Engine.

  3. 在 [物件總管] 中,展開 [資料庫]。In Object Explorer, expand Databases.

  4. 以滑鼠右鍵按一下您想要備份,並指向 [工作],然後按一下 [備份資料庫。Right-click the database that you want to back up, point to Tasks, and then click Back Up.

  5. 在 [備份資料庫] 對話方塊中,確認資料庫名稱。In the Back Up Database dialog box, confirm the database name.

  6. 接下來,選取您想要從 [備份類型] 清單中執行備份的類型。如需所要使用之備份類型的詳細資訊,請參閱 <復原模式 (SQL 伺服器)Next, select the kind of backup that you want to perform from the Backup type list. For more information about which backup type to use, see Recovery Models (SQL Server).

  7. 在 [備份元件] 區域中,按一下 [資料庫]。In the Backup component area, click Database.

  8. 使用所提供的預設名稱或指定備份組名稱] 文字方塊中的名稱。Either use the default name that is provided or specify a name for the backup set in the Name text box.

  9. 在 [目的地] 區域中,指定您要儲存備份的位置。In the Destination area, specify where you want to store the backup.

  10. 按一下 [備份資料庫的[確定]Click OK to back up the database.

  11. 針對每個伺服器陣列資料庫重複步驟 1-10。Repeat steps 1-10 for each farm database.

另請參閱See also

概念Concepts

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

在 SharePoint Server 中備份伺服器陣列Back up farms in SharePoint Server

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