SharePoint Server 中備份與還原的最佳作法Backup and restore best practices in SharePoint Server

摘要: 了解如何在備份與還原 SharePoint Server 2016 和 SharePoint 2013 伺服器陣列之前實作最佳作法。Summary: Learn how to implement best practices before you back up and restore a SharePoint Server 2016 and SharePoint 2013 farm.

備份與還原的最佳作法有助於確保 SharePoint Server 中的備份與還原作業成功完成,並且可保護環境不會遭受資料遺失或連續性間斷的傷害。Best practices for backup and restore help make sure that backup and restore operations in SharePoint Server are successful and that the environment is protected against data loss or continuity gaps.

SharePoint 備份與還原作業的效能最佳作法Performance best practices for SharePoint backup and restore operations

備份與還原作業在執行時會耗用伺服器資源並且限制伺服器的效能。請遵循這些建議作法來協助降低備份或還原工作對伺服器資源的使用,並提高伺服器的效能。Backup and restore operations consume server resources and limit server performance while the operations are running. Follow these recommended practices to help reduce resource usage and increase the performance of servers and the backup or restore task.

將 SQL Server 與備份位置之間的延遲降至最低Minimize latency between SQL Server and the backup location

一般而言,備份至資料庫伺服器上的本機磁碟而非網路磁碟機就很有效率。之後您可以將資料複製到網路上的共用資料夾。網路磁碟機與資料庫伺服器之間的延遲如果為 1 毫秒或更低,執行效果就相當良好。In general, it is efficient to back up to a local disk on the database server instead of a network drive. You can then copy the data later to a shared folder on the network. Network drives with 1 millisecond or less latency between them and the database server perform well.

注意

如果您無法備份至本機磁碟機,請使用在延遲上類似的網路磁碟機。因為網路份會受到網路錯誤的影響,請在備份動作完成後驗證作業是否成功。如需詳細資訊,請參閱<備份裝置 (SQL Server)>中的<備份至網路共用上的檔案>。If you cannot back up to local drives, use network drives with similar latency. Because network backups are subject to network errors, verify the backup action after it finishes. For more information, see "Backing Up to a File on a Network Share" in Backup Devices (SQL Server).

為避免 I/O 出現瓶頸,請從執行 SQL Server 2008 R2 Service Pack 1 (SP1) 及 SQL Server 2012、SQL Server 2014 或 SQL Server 2008 R2 Service Pack 1 (SP1) 及 SQL Server 2012 的磁碟執行主要備份至其他磁碟。如需詳細資訊,請參閱<定義磁碟檔案的邏輯備份裝置 (SQL Server)>。To avoid I/O bottlenecks, perform the main backup to a separate disk from the disk running SQL Server 2008 R2 with Service Pack 1 (SP1) and SQL Server 2012, SQL Server 2014 or, SQL Server 2008 R2 with Service Pack 1 (SP1) and SQL Server 2012. For more information, see Define a Logical Backup Device for a Disk File (SQL Server).

根據設計,大部分備份工作會耗用所有可用的 I/O 資源來完成工作。因此,您可能會發現磁碟佇列的情況,造成 I/O 要求的延遲比平常要久。這是很平常的現象,不應視為問題。如需詳細資訊,請參閱<監視磁碟使用量>。By design, most backup jobs consume all available I/O resources to complete the job. Therefore, you might see disk queuing, which can result in greater than usual latency for I/O requests. This is typical and should not be considered a problem. For more information, see Monitor Disk Usage.

避免處理衝突Avoid processing conflicts

請勿在使用者需要存取系統時執行備份工作。系統一般是全年無休的。最佳作法是一律執行增量備份,以預防伺服器失敗的情況發生。請考慮錯開備份時間,以免在同一時間備份所有的資料庫。Do not run backup jobs during times when users need access to the system. Typically, systems run 24 hours a day, seven days a week. A best practice is to always run incremental backups to safeguard against server failure. Consider staggering backups so that all databases are not backed up at the same time.

別讓資料庫變得太大,可讓復原快速進行Keep databases small for faster recovery times

別讓資料庫變得太大,可加快備份與還原的速度。例如,對於 Web 應用程式使用多個內容資料庫,而非一個大型的內容資料庫。如需詳細資訊,請參閱<SharePoint Server 中的資料庫類型和描述>。Keep databases small to speed both backup and restore. For example, use multiple content databases for a web application instead of one large content database. For more information, see Database types and descriptions in SharePoint Server.

如需支援 SharePoint Server 2016 的資料庫圖形概觀,請參閱 快速參考指南:SharePoint Server 2016 資料庫。您也可以下載這個 SharePoint Server 2016 資料庫海報,作為 PDFVisio 檔案。For a graphical overview of the databases that support SharePoint Server 2016, see Quick reference guide: SharePoint Server 2016 databases. You can also download this SharePoint Server 2016 database poster, as either a PDF or Visio file.

對大型資料庫使用增量備份Use incremental backups for large databases

請對大型資料庫使用增量備份,因為備份較為快速,而且可以維持環境的效能。雖然從完整備份還原比從增量備份還原較為快速,但是連續增量備份會將資料遺失的情況降低最低。如需備份類型的詳細資訊,請參閱備份概觀 (SQL Server)Use incremental backups for large databases because you can make them quickly and maintain performance of the environment. Although you can restore full backups faster than incremental backups, continuous incremental backups minimize data loss. For more information about types of backups, see Backup Overview (SQL Server).

在備份期間使用壓縮Use compression during backup

在某些情況下,您可以使用壓縮來減少備份的大小,並縮短完成每次備份的時間。SQL Server 2008 Enterprise 中已引入備份壓縮功能。備份壓縮會增加 CPU 使用量,而這可能會影響 SQL Server 並行作業。In some circumstances, you can use compression to decrease the size of backups and the time to complete each backup. Backup compression was introduced in SQL Server 2008 Enterprise. Backup compression increases CPU usage and this can affect SQL Server concurrent operations.

重要

SharePoint Server 支援 SQL Server 備份壓縮。針對 SharePoint Server 資料庫不支援 SQL Server 資料壓縮。SharePoint Server supports SQL Server backup compression. SQL Server data compression is not supported for SharePoint Server databases.

如需備份壓縮會如何影響 SQL Server 效能的詳細資訊,請參閱<備份壓縮 (SQL Server)>。For more information about how backup compression affects performance in SQL Server, see Backup Compression (SQL Server).

遵循 SQL Server 備份與還原最佳化建議Follow SQL Server backup and restore optimization recommendations

SQL Server 備份合併使用完整、差異及交易記錄檔備份 (針對完整或大量記錄復原模式),將復原時間降至最低。建立差異式資料庫備份通常比建立完整的資料庫備份快,並可減少復原資料庫所需的交易記錄檔數量。SQL Server backups use a combination of full, differential, and transaction log backups (for the full or bulk-logged recovery model) to minimize recovery time. Differential database backups are usually faster to create than full database backups and reduce the number of transaction logs required to recover the database.

若您使用完整復原模式,建議您定期截斷交易記錄檔以避免發生維護上的問題。If you are using the full recovery model, we recommend that you periodically truncate the transaction log files to avoid maintenance issues.

如需如何最佳化 SQL Server 備份與還原效能的詳細建議,請參閱<最佳化 SQL Server 中的備份和還原效能>。For detailed recommendations about how to optimize SQL Server backup and restore performance, see Optimizing Backup and Restore Performance in SQL Server.

若您使用 RAID,請使用 RAID 10Use RAID 10 if you use RAID

請仔細考慮是否要在備份資料的目標裝置上使用獨立磁碟容錯陣列 (RAID)。例如,RAID 5 的寫入效能較慢,大約和單一磁碟寫入的速度相同。這是因為 RAID 5 必須維護同位資訊。RAID 10 可提供較快速的備份,因為不需要管理同位資訊,所以讀寫資料比較快。如需如何使用 RAID 來搭配備份的詳細資訊,請參閱設定 RAID 以達到最大的 SQL Server I/O 輸送量RAID 層級與 SQL ServerCarefully consider whether to use redundant array of independent disks (RAID) on the device to which you back up data. For example, RAID 5 has slow write performance, approximately the same speed as for a single disk. This is because RAID 5 has to maintain parity information. RAID 10 can provide faster backups because it doesn't need to manage parity. Therefore, it reads and writes data faster. For more information about how to use RAID with backups, see Configure RAID for maximum SQL Server I/O throughput and RAID Levels and SQL Server.

設定 SharePoint 設定以改善備份或還原效能Configure SharePoint settings to improve backup or restore performance

在 PowerShell 中您僅可設定檔案壓縮與記錄檔設定。在 SharePoint 管理中心網站與 PowerShell 中您都可設定備份與還原執行緒,以提高備份或還原的效率與效能。You can only configure file compression and log file settings in PowerShell. You can configure backup and restore threads in both the SharePoint Central Administration website and PowerShell to increase backup or restore efficiency and performance.

如果您使用 Export-SPWeb PowerShell Cmdlet,則可使用 NoFileCompression 參數。依據預設,SharePoint Server 在匯出 Web 應用程式、網站集合、清單或文件庫時會使用檔案壓縮。您在匯出與匯入時可使用此參數來防止檔案壓縮。檔案壓縮會使用高達 30% 以上的資源。不過,匯出的檔案會佔用大約 25% 以下的磁碟空間。如果在匯出時使用 NoFileCompression 參數,將同一內容匯入時也必須使用這個參數。If you use the Export-SPWeb PowerShell cmdlet, you can use the NoFileCompression parameter. By default, SharePoint Server uses file compression while exporting web applications, site collection, lists, or document libraries. You can use this parameter to suppress file compression while exporting and importing. File compression can use up to 30% more resources. However, the exported file uses approximately 25% less disk space. If you use the NoFileCompression parameter when you export, you have to also use it when you import the same content.

您也可使用 NoLogFile 參數。依據預設,SharePoint Server 一律會在您匯出內容時建立記錄檔。雖然您可使用此參數來防止記錄檔的建立以節省資源,還是建議您一律建立記錄檔。疑難排解時記錄檔非常重要,而且建立記錄檔不會使用非常多的 CPU 或記憶體等資源。You can also use the NoLogFile parameter. By default, SharePoint Server always creates a log file when you export content. Although you can use this parameter to suppress log file creation to save resources, we recommend that you always create logs. Logs are important for troubleshooting and log creation does not use many resources such as CPU or memory.

當您使用 Backup-SPFarm Cmdlet 時,還可使用 BackupThreads 參數,以指定備份程序期間 SharePoint Server 會使用多少執行緒。較高數量的執行緒會在備份期間耗用較多的資源,但是執行備份所需的整體時間會減少。因為每條執行緒都會記錄在記錄檔中,執行緒的數量確實會影響記錄檔的解譯。依據預設會使用三條執行緒。可用執行緒的最大數為 10。When you use the Backup-SPFarm cmdlet, you can also use the BackupThreads parameter to specify how many threads SharePoint Server will use during the backup process. A higher number of threads will consume more resources during backup. But the overall time to make the backup is decreased. Because each thread is recorded in the log files, the number of threads does affect log file interpretation. By default, three threads are used. The maximum number of available threads is 10.

注意

您也可透過管理中心,在「預設備份與還原設定」頁面上的 [備份與還原] 區段中找到備份執行緒設定。The backup threads setting is also available through Central Administration on the Default Backup and Restore Settings page in the Backup and Restore section.

在決定要使用的工具時,請考慮網站集合大小Consider site collection size when you determine the tools to use

如果除了伺服器陣列層級或資料庫層級備份之外,企業還要求網站集合備份,請根據網站集合的大小來選擇備份工具。If the business requires site collection backups in addition to farm-level or database-level backups, choose a backup tool that is based on the size of the site collection.

  • 15-100 GB︰使用 Backup-SPSite、SharePoint Server 工具、SQL Server 工具或其他資料庫備份工具,以保護包含網站集合的內容資料庫。如需詳細資訊,請參閱<在 SharePoint Server 中備份網站集合>。15-100 GB: Usethe Backup-SPSite, a SharePoint Server tool, a SQL Server tool, or other database backup tool to protect the content database that contains the site collection. For more information, see Back up site collections in SharePoint Server.

  • 大於 100 GB︰使用差異備份解決方案 (如 SQL Server 或 System Center Data Protection Manager R2),而不使用內建的備份與復原工具。Larger than 100 GB: Use a differential backup solution, such as SQL Server or System Center Data Protection Manager R2, instead of the built-in backup and recovery tools.

備份 SharePoint 伺服器陣列的品質保證最佳作法Quality assurance best practices to back up a SharePoint farm

請遵循這些最佳作法以確保伺服器陣列環境備份的品質,並減少資料遺失的機會。Follow these best practices to help ensure the quality of the backups of the farm environment and reduce the chances of data loss.

確定有足夠的儲存空間Ensure you have enough storage space

請確定系統有足夠的磁碟空間可容納備份。可在管理中心中設定備份工作來驗證所需的磁碟空間。Be certain that the system has enough disk space to accommodate the backup. Configure a backup job in Central Administration to verify the required disk space.

例行測試備份品質Routinely test backup quality

請例行測試備份並驗證備份的一致性。執行練習復原作業以驗證備份的內容,並確定是否可還原整個環境。若要為分佈在不同地理區域之環境的災害復原進行準備,請設定遠端伺服器陣列。接著可使用資料庫附加方法,將資料庫的複本上傳至遠端伺服器陣列並將使用者重新導向。請定期執行測試資料復原動作,以驗證該程序是否可正確備份檔案。測試還原會暴露出軟體驗證中不會出現的硬體問題,同時也可確定是否符合復原時間目標 (RTO)。Routinely test backups and validate their consistency. Run practice recovery operations to validate the contents of the backup and to make sure that you can restore the complete environment. To prepare for disaster recovery of geographically dispersed environments, set up a remote farm. Then you can restore the environment by using the database-attach method to upload a copy of the database to the remote farm and redirect users. Periodically perform a trial data recovery action to verify that the process correctly backs up files. A trial restoration can expose hardware problems that do not come up with software verifications and can also to make sure that the recovery time objectives (RTO) are met.

備份 ULS 追蹤記錄檔Back up ULS trace logs

SharePoint Server 備份程序不會備份統一登錄服務 (ULS) 追蹤記錄檔。ULS 追蹤記錄檔中的資料對於效能分析、疑難排解及監控服務等級協定非常有用。因此,請在例行維護中保護此項資料。The SharePoint Server backup process doesn't back up the Unified Logging Service (ULS) trace logs. Data in ULS trace logs can be useful for performance analysis, troubleshooting, and monitoring compliance with service level agreements. Therefore, protect this data as part of the routine maintenance.

依據預設,SharePoint 記錄檔位於 C:\Program files\Common Files\Microsoft Shared\Web Server Extensions\<16 或 15>\Logs。檔案的命名規則為伺服器名稱加上日期與時間戳記。SharePoint 追蹤記錄檔會根據固定間隔建立,以及當您使用 IISRESET 命令時建立。By default, SharePoint log files are at C:\Program files\Common Files\Microsoft Shared\Web Server Extensions\<16 or 15>\Logs. The files are named with the server name followed by the date and time stamp. The SharePoint trace logs are created at set intervals and when you use the IISRESET command.

在異地儲存備份檔案的複本Store a copy of backup files off-site

為了保護資料不因自然災害摧毀主資料中心而造成遺失,請在伺服器之外的其他地點保留備份的複本。複本有助於避免重要資料的遺失。以最佳作法而言,請保存備份媒體的三份複本,並將至少一份複本保存在異地的控制環境下。這應該包括所有備份與復原資料、文件、資料庫與交易記錄檔備份,以及使用狀況與追蹤記錄檔備份。To safeguard against loss from a natural disaster that destroys the primary data center, maintain duplicate copies of backups in separate locations from the servers. Duplicate copies can help prevent the loss of critical data. As a best practice, keep three copies of the backup media, and keep at least one copy offsite in a controlled environment. This should include all backup and recovery materials, documents, database and transaction log backups, and usage and trace log backups.

備份與還原 SharePoint Server 的程序性最佳作法Procedural best practices to back up and restore SharePoint Server

請在規劃及執行備份與還原作業時,使用下列程序性最佳作法。Use the following procedural best practices to plan and perform backup and restore operations.

使用 FQDN 伺服器名稱Use FQDN server names

參照不同網域中的伺服器時,請一律使用完整網域名稱 (FQDN)。When you refer to servers in a different domain, always use fully qualified domain names (FQDN).

保存精確的記錄Keep accurate records

當您部署 SharePoint Server 時,請記錄所建立的帳戶、電腦名稱、密碼及設定選項。將此資訊保存在安全無虞的地點。如有可能,保存多份記錄以確保此資訊一定可供使用。When you deploy SharePoint Server, record the accounts that you create, the computer names, passwords, and setup options. Keep this information in a safe and secure location. Possibly, keep multiple records to make sure this information is always available.

準備好復原環境Have a recovery environment ready

在您的災害復原策略中,於次要地點使用伺服器陣列來驗證還原作業是否成功。如需詳細資訊,請參閱<選擇 SharePoint Server 的災害復原策略>。在災害復原的情況下,您就可使用資料庫附加的方法,將資料庫的複本上傳至遠端伺服器陣列並將使用者重新導向,即可還原環境。如需詳細資訊,請檢閱並遵循<在 SharePoint Server 中還原伺服器陣列>中的步驟。至於高可用性解決方案,您可設定一個與實際執行環境執行相同版本軟體的待命環境,讓您可快速還原資料庫及復原文件。如需詳細資訊,請參閱<說明高可用性>。Use a farm in a secondary location to validate the success of restore operations as part of your disaster recovery strategy. For more information, see Choose a disaster recovery strategy for SharePoint Server. In a disaster recovery situation, you can then restore the environment by using the database-attach method to upload a copy of the database to the remote farm and redirect users. For more information, review and follow the steps in Restore farms in SharePoint Server. Also for a high availability solution, you can set up a standby environment that runs the same version of software as the production environment so that you can restore the databases and recover documents quickly. For more information, see Describing high availability.

排程備份作業Schedule backup operations

使用 PowerShell 備份與復原 Cmdlet 來建立指令碼檔案 (*.ps1),然後使用 Windows 工作排程器,排程該指令碼檔案的執行時間。如此可確保所有的備份作業會在最佳的時間執行,也就是在系統最不忙碌,而且使用者也不存取系統的時候。如需詳細資訊,請參閱下列文章︰Use PowerShell backup and recovery cmdlets to create a script file (*.ps1) and then schedule it to run with Windows Task Scheduler. This makes sure that all backup operations are run at the best time when the system is least busy and users are not accessing it. For more information, see the following:

使用 SQL FILESTREAM 提供者並搭配 BLOB 儲存Use the SQL FILESTREAM provider with BLOB storage

SharePoint Server 伺服器陣列支援遠端 BLOB 儲存 (RBS)。在 SharePoint Server 中使用 RBS 有其優缺點。在 SharePoint 伺服器陣列中使用 RBS 的其中一個相關限制是,System Center Data Protection Manager 無法使用 FILESTREAM 提供者來備份或還原 RBS。SharePoint Server 支援 FILESTREAM 提供者來進行備份與還原作業。在 SharePoint 伺服器陣列中使用 RBS 的一個優點是,您可使用 SharePoint 工具或 SQL Server 工具來備份與還原其中定義了遠端 BLOB 存放區 (RBS) 的內容資料庫。如此會將 RBS 和內容資料庫同時進行備份與還原。我們不建議您以其他還原方法來使用 RBS。如需使用 RBS 之優點與限制的詳細資訊,請參閱<決定在 SharePoint Server 中使用 RBS>。下載包含 RBS 的 Microsoft SQL Server 2014 Feature PackRemote BLOB Storage (RBS) is supported in a SharePoint Server farm. There are both pros and cons associated with using RBS in SharePoint Server. One related limitation of RBS with a SharePoint farm is that System Center Data Protection Manager cannot use the FILESTREAM provider to back up or restore RBS. SharePoint Server supports the FILESTREAM provider for backup and restore operations. A benefit of RBS with a SharePoint farm is that you can use either SharePoint tools or SQL Server tools to back up and restore the content database with the Remote BLOB Store (RBS) defined. This backs up and restores both the RBS and the content database. We do not recommend that you use RBS with other restore methods. For more information about the benefits and limitations of using RBS, see Deciding to use RBS in SharePoint Server. Download Microsoft SQL Server 2014 Feature Packthat includes RBS.

注意

SharePoint Server 2016 支援 SQL Server 2014 隨附的 FILESTREAM 提供者。如需詳細資訊,請參閱<啟用及設定 FILESTREAM>。SharePoint Server 2016 supports the FILESTREAM provider that is included with SQL Server 2014. For more information, see Enable and Configure FILESTREAM.

注意

SharePoint Server 2013 支援 Microsoft® SQL Server® 2008 R2 功能套件內含的 FILESTREAM 提供者。SQL Server 2012 和 SQL Server 2014 安裝媒體包含選用的 RBS 附加元件。SharePoint Server 2013 supports the FILESTREAM provider that is included in the Microsoft® SQL Server® 2008 R2 Feature Pack. The SQL Server 2012 and SQL Server 2014 installation media includes RBS as an optional add-on component.

另請參閱See also

概念Concepts

SharePoint Server 的備份與復原概觀Overview of backup and recovery in SharePoint Server

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

在 SharePoint Server 中準備備份及還原伺服器陣列Prepare to back up and restore farms in SharePoint Server

其他資源Other Resources

資料庫備份加密Database Backup Encryption