自動備份Automated backups

SQL Database 會自動建立保留7到35天的資料庫備份,並使用 Azure讀取權限異地冗余儲存體(RA-GRS)來確保即使資料中心無法使用,也會保留它們。SQL Database automatically creates the database backups that are kept between 7 and 35 days, and uses Azure read-access geo-redundant storage (RA-GRS) to ensure that they are preserved even if the data center is unavailable. 這些備份會自動建立。These backups are created automatically. 資料庫備份可保護資料免於意外損毀或刪除,是商務持續性和災害復原策略中不可或缺的一部分。Database backups are an essential part of any business continuity and disaster recovery strategy because they protect your data from accidental corruption or deletion. 如果您的安全性規則需要備份可供使用一段時間(最多10年),您可以在單一資料庫和彈性集區上設定長期保留If your security rules require that your backups are available for an extended period of time (up to 10 years), you can configure a long-term retention on Singleton databases and Elastic pools.

注意

本文提供如何從裝置或服務上刪除個人資料的步驟,而且可以用來支援 GDPR 的義務。This article provides steps for how to delete personal data from the device or service and can be used to support your obligations under the GDPR. 如果您想要尋找有關 GDPR 的一般資訊,請參閱 Service Trust 入口網站的 GDPR 區段If you’re looking for general info about GDPR, see the GDPR section of the Service Trust portal.

什麼是 SQL Database 備份What is a SQL Database backup

SQL Database 使用 SQL Server 的技術,每週建立完整備份、每12小時進行差異備份,以及每5-10 分鐘建立一次交易記錄備份SQL Database uses SQL Server technology to create full backups every week, differential backups every 12 hours, and transaction log backups every 5-10 minutes. 這些備份會儲存在GRS 儲存體 blob中,並複寫到配對的資料中心,以防止資料中心中斷。The backups are stored in RA-GRS storage blobs that are replicated to a paired data center for protection against a data center outage. 在您還原資料庫時,服務會判斷需要還原的完整、差異及交易記錄備份。When you restore a database, the service figures out which full, differential, and transaction log backups need to be restored.

您可以使用這些備份︰You can use these backups to:

  • 使用 [Azure 入口網站]、[Azure PowerShell]、[Azure CLI] 或 [REST API],將現有的資料庫還原到保留期限內的過去時間點。Restore an existing database to a point-in-time in the past within the retention period using the Azure portal, Azure PowerShell, Azure CLI, or REST API. 在單一資料庫和彈性集區中,這項作業會在與原始資料庫相同的伺服器中建立新的資料庫。In Single database and Elastic pools, this operation will create a new database in the same server as the original database. 在受控執行個體中,這項作業可以在相同的訂用帳戶下建立資料庫複本或相同或不同的受控執行個體。In Managed Instance, this operation can create a copy of the database or same or different Managed Instance under the same subscription.
  • 已刪除的資料庫還原至其刪除或保留期間內的任何時間。Restore a deleted database to the time it was deleted or anytime within the retention period. 已刪除的資料庫只能在原始資料庫建立所在的相同邏輯伺服器或受控執行個體中進行還原。The deleted database can only be restored in the same logical server or Managed Instance where the original database was created.
  • 將資料庫還原到另一個地理區域Restore a database to another geographical region. 異地還原可讓您在無法存取您的伺服器和資料庫時,從地理災害中復原。Geo-restore allows you to recover from a geographic disaster when you cannot access your server and database. 在世界各地任何現有的伺服器中建立新的資料庫。It creates a new database in any existing server anywhere in the world.
  • 如果資料庫已設定長期保留原則(LTR),請在單一資料庫或彈性集區上從特定長期備份還原資料庫Restore a database from a specific long-term backup on Single Database or Elastic Pool if the database has been configured with a long-term retention policy (LTR). LTR 可讓您使用Azure 入口網站Azure PowerShell來還原舊版本的資料庫,以滿足合規性要求或執行舊版的應用程式。LTR allows you to restore an old version of the database using the Azure portal or Azure PowerShell to satisfy a compliance request or to run an old version of the application. 如需詳細資訊,請參閱長期保存For more information, see Long-term retention.
  • 若要執行還原,請參閱從備份還原資料庫To perform a restore, see restore database from backups.

注意

在 Azure 儲存體中,「複寫」一詞指的是將檔案從某個位置複製到另一個位置。In Azure storage, the term replication refers to copying files from one location to another. SQL 的「資料庫複寫」指的是保持多個次要資料庫與主要資料庫同步。SQL's database replication refers to keeping multiple secondary databases synchronized with a primary database.

您可以使用下列範例來嘗試其中一些作業:You can try some of these operations using the following examples:

Azure 入口網站The Azure portal Azure PowerShellAzure PowerShell
變更備份保留期Change backup retention 單一資料庫Single Database
受控執行個體Managed Instance
單一資料庫Single Database
受控執行個體Managed Instance
變更長期備份保留期Change Long-term backup retention 單一資料庫Single database
受控執行個體-N/AManaged Instance - N/A
單一資料庫Single Database
受控執行個體-N/AManaged Instance - N/A
從時間點還原資料庫Restore database from point-in-time 單一資料庫Single database 單一資料庫Single database
受控執行個體Managed Instance
還原已刪除的資料庫Restore deleted database 單一資料庫Single database 單一資料庫Single database
受控執行個體Managed Instance
從 Azure Blob 儲存體還原資料庫Restore database from Azure Blob Storage 單一資料庫-N/ASingle database - N/A
受控執行個體-N/AManaged Instance - N/A
單一資料庫-N/ASingle database - N/A
受控執行個體Managed Instance

備份會保留多久的時間How long are backups kept

所有 Azure SQL 資料庫(單一、集區和受控實例資料庫)的預設備份保留期限為7天。All Azure SQL databases (single, pooled, and managed instance databases) have a default backup retention period of seven days. 您可以將備份保留期限變更為最多35天You can change backup retention period up to 35 days.

如果您刪除資料庫,則 SQL Database 會以保存線上資料庫備份的相同方式保存備份。If you delete a database, SQL Database will keep the backups in the same way it would for an online database. 例如,如果您刪除保留期間為七天的基本資料庫,則為期四天的備份還會再儲存三天。For example, if you delete a Basic database that has a retention period of seven days, a backup that is four days old is saved for three more days.

如果您需要保留備份的時間超過保留週期上限,則可以修改備份的屬性,以將一或多個長期保留週期新增至資料庫。If you need to keep the backups for longer than the maximum retention period, you can modify the backup properties to add one or more long-term retention periods to your database. 如需詳細資訊,請參閱長期保存For more information, see Long-term retention.

重要

如果您刪除裝載 SQL 資料庫的 Azure SQL Server,則也會一併刪除所有屬於該伺服器的彈性集區和資料庫,且無法復原。If you delete the Azure SQL server that hosts SQL databases, all elastic pools and databases that belong to the server are also deleted and cannot be recovered. 您無法還原已刪除的伺服器。You cannot restore a deleted server. 但是,如果您已設定長期保留,則不會刪除具有 LTR 之資料庫的備份,而且可以還原這些資料庫。But if you configured long-term retention, the backups for the databases with LTR will not be deleted and these databases can be restored.

備份發生頻率為何How often do backups happen

時間點還原的備份Backups for point-in-time restore

SQL Database 透過自動建立完整備份、差異備份和交易記錄備份,以支援自助式時間點還原 (PITR)。SQL Database supports self-service for point-in-time restore (PITR) by automatically creating full backup, differential backups, and transaction log backups. 根據計算大小和資料庫活動量的頻率,完整資料庫備份會每週建立,差異資料庫備份通常每隔 12 小時建立,而交易記錄備份通常每隔 5-10 分鐘建立。Full database backups are created weekly, differential database backups are generally created every 12 hours, and transaction log backups are generally created every 5 - 10 minutes, with the frequency based on the compute size and amount of database activity. 建立資料庫之後,會立即排程第一次完整備份。The first full backup is scheduled immediately after a database is created. 通常會在 30 分鐘內完成,但如果資料庫很大,則時間可能更久。It usually completes within 30 minutes, but it can take longer when the database is of a significant size. 比方說,在還原的資料庫或資料庫複本上,初始備份可能需要較長的時間。For example, the initial backup can take longer on a restored database or a database copy. 第一次完整備份之後,將會自動排程進一步的備份,並在背景中以無訊息方式管理。After the first full backup, all further backups are scheduled automatically and managed silently in the background. 資料庫備份的確切時間,依 SQL Database 服務整體系統工作負載維持平衡而決定。The exact timing of all database backups is determined by the SQL Database service as it balances the overall system workload. 您無法變更或停用備份作業。You cannot change or disable the backup jobs.

PITR 備份為異地備援,並受到 Azure 儲存體跨區域複寫保護The PITR backups are geo-redundant and protected by Azure Storage cross-regional replication

如需詳細資訊,請參閱還原時間點For more information, see Point-in-time restore

長期保留的備份Backups for long-term retention

單一和集區資料庫提供選項讓您在 Azure Blob 儲存體中設定完整備份的長期保留 (LTR),最長可達 10 年。Single and pooled databases offer the option of configuring long-term retention (LTR) of full backups for up to 10 years in Azure Blob storage. 如果啟用 LTR 原則,則會將每週完整備份自動複製到不同的 RA-GRS 儲存體容器。If LTR policy is enabled, the weekly full backups are automatically copied to a different RA-GRS storage container. 為了符合不同的合規性需求,您可以針對每週、每月和/或每年備份選取不同的保留期限。To meet different compliance requirement, you can select different retention periods for weekly, monthly and/or yearly backups. 儲存體耗用量取決於選取的備份頻率和保留期間。The storage consumption depends on the selected frequency of backups and the retention period(s). 您可以使用 LTR 定價計算機來估算 LTR 儲存體的成本。You can use the LTR pricing calculator to estimate the cost of LTR storage.

與 PITR 類似,LTR 備份為異地備援,並受到 Azure 儲存體跨區域複寫保護。Like PITR, the LTR backups are geo-redundant and protected by Azure Storage cross-regional replication.

如需詳細資訊,請參閱長期備份保留For more information, see Long-term backup retention.

儲存成本Storage costs

針對單一資料庫和受控實例,會免費提供等於100% 資料庫大小的備份儲存體數量下限。For single databases and managed instances, a minimum backup storage amount equal to 100% of database size is provided at no extra charge. 若為彈性集區,則會免費提供等於為集區配置之資料儲存體的100% 的最小備份儲存體數量。For elastic pools, a minimum backup storage amount equal to 100% of the allocated data storage for the pool is provided at no extra charge. 備份儲存體的額外使用量會按每月每 GB 來收費。Additional consumption of backup storage will be charged in GB/month. 這項額外的耗用量將取決於個別資料庫的工作負載和大小。This additional consumption will depend on the workload and size of the individual databases.

您可以使用 Azure 訂用帳戶成本分析來判斷您目前的備份儲存體費用。You can use Azure subscription cost analysis to determine your current spending on backup storage.

備份儲存體成本分析

如果您移至訂用帳戶並開啟 [成本分析] 分頁,則可以選取 [計量子類別 mi] [ pitr 備份儲存體],以查看目前的備份成本和費用預測。If you go to your subscription and open Cost Analysis blade, you can select meter subcategory mi pitr backup storage to see your current backup cost and charge forecast. 您也可以包含其他計量子類別,例如受控實例一般目的儲存體受控實例一般目的-計算第5代,以比較備份儲存體成本與其他成本類別。You can also include other meter subcategories such as managed instance general purpose - storage or managed instance general purpose - compute gen5 to compare backup storage cost with other cost categories.

注意

您可以將保留期限變更為7天,以降低備份儲存體成本。You can change retention period to 7 days to reduce the backup storage cost.

如需儲存體價格的詳細資訊,請參閱定價頁面。For more information about storage prices, see the pricing page.

備份是否已加密Are backups encrypted

如果您的資料庫使用 TDE 加密,則備份會在靜止時自動加密 (包括 LTR 備份)。If your database is encrypted with TDE, the backups are automatically encrypted at rest, including LTR backups. Azure SQL 資料庫啟用 TDE 時,也會加密備份。When TDE is enabled for an Azure SQL database, backups are also encrypted. 所有新的 Azure SQL 資料庫預設都會設定為啟用 TDE。All new Azure SQL databases are configured with TDE enabled by default. 如需 TDE 的詳細資訊,請參閱 Azure SQL Database 的透明資料加密For more information on TDE, see Transparent Data Encryption with Azure SQL Database.

Microsoft 如何確保備份完整性How does Microsoft ensure backup integrity

Azure SQL Database 工程小組會持續自動測試在邏輯伺服器和彈性集區中的資料庫之自動資料庫備份的還原(這在受控執行個體中無法使用)。On an ongoing basis, the Azure SQL Database engineering team automatically tests the restore of automated database backups of databases placed in Logical servers and Elastic pools (this is not available in Managed Instance). 在還原時間點時,資料庫也會使用 DBCC CHECKDB 來接收完整性檢查。Upon point-in-time restore, databases also receive integrity checks using DBCC CHECKDB.

受控執行個體會在完成遷移之後,使用原生 RESTORE 命令或資料移轉服務還原的 CHECKSUM 資料庫,自動進行初始備份。Managed Instance takes automatic initial backup with CHECKSUM of the databases restored using native RESTORE command or Data Migration Service once the migration is completed.

在完整性檢查期間找到的任何問題都會對工程小組發出警示。Any issues found during the integrity check will result in an alert to the engineering team. 如需有關 Azure SQL Database 中資料完整性的詳細資訊,請參閱 Azure SQL Database 中的資料完整性For more information about data integrity in Azure SQL Database, see Data Integrity in Azure SQL Database.

自動化備份對合規性的影響為何How do automated backups impact compliance

當您將資料庫從預設 PITR 保留 35 天的以 DTU 為基礎的服務層級遷移至以虛擬核心為基礎的服務層級時,會保留 PITR 保留,確保不會危害您應用程式的資料復原原則。When you migrate your database from a DTU-based service tier with the default PITR retention of 35 days, to a vCore-based service tier, the PITR retention is preserved to ensure that your application's data recovery policy is not compromised. 如果預設保留週期不符合合規性需求,您可以使用 PowerShell 或 REST API 變更 PITR 保留週期。If the default retention doesn't meet your compliance requirements, you can change the PITR retention period using PowerShell or REST API. 如需詳細資訊,請參閱變更備份保留週期For more information, see Change Backup Retention Period.

注意

本文提供如何從裝置或服務上刪除個人資料的步驟,而且可以用來支援 GDPR 的義務。This article provides steps for how to delete personal data from the device or service and can be used to support your obligations under the GDPR. 如果您想要尋找有關 GDPR 的一般資訊,請參閱 Service Trust 入口網站的 GDPR 區段If you’re looking for general info about GDPR, see the GDPR section of the Service Trust portal.

如何變更 PITR 備份保留期間How to change the PITR backup retention period

您可以使用 Azure 入口網站、PowerShell 或 REST API 來變更預設的 PITR 備份保留期限。You can change the default PITR backup retention period using the Azure portal, PowerShell, or the REST API. 支援的值為:7、14、21、28 或 35 天。The supported values are: 7, 14, 21, 28 or 35 days. 下列範例說明如何將 PITR 保留變更為 28 天。The following examples illustrate how to change PITR retention to 28 days.

警告

如果您降低目前的保留期間,則無法再使用新保留期間之前的所有現有備份。If you reduce the current retention period, all existing backups older than the new retention period are no longer available. 如果您延長目前的保留期間,則 SQL Database 將保留現有備份,直到達到較長的保留期間為止。If you increase the current retention period, SQL Database will keep the existing backups until the longer retention period is reached.

注意

這些 API 只會影響 PITR 保留期間。These APIs will only impact the PITR retention period. 如果您已將資料庫設定為 LTR,則它不受影響。If you configured LTR for your database, it will not be impacted. 如需如何變更 LTR 保留期間的詳細資訊,請參閱長期保留For more information about how to change the LTR retention period(s), see Long-term retention.

使用 Azure 入口網站變更 PITR 備份保留期限Change PITR backup retention period using Azure portal

若要使用 Azure 入口網站來變更 PITR 備份保留期限,請流覽至您想要在入口網站中變更其保留期限的伺服器物件,然後根據您要修改的伺服器物件,選取適當的選項。To change the PITR backup retention period using the Azure portal, navigate to the server object whose retention period you wish to change within the portal and then select the appropriate option based on which server object you're modifying.

單一 Azure SQL 資料庫的 PITR 備份保留變更會在伺服器層級執行。Change of PITR backup retention for single Azure SQL Databases is performed at the server level. 在伺服器層級進行的變更會套用至該伺服器上的資料庫。Change made at the server level applies to databases on that server. 若要從 Azure 入口網站變更 Azure SQL Database server 的 PITR,請流覽至 [伺服器總覽] 分頁,按一下導覽功能表上的 [管理備份],然後按一下巡覽列上的 [設定保留]。To change PITR for Azure SQL Database server from Azure portal, navigate to the server overview blade, click on Manage Backups on the navigation menu, and then click on Configure retention at the navigation bar.

變更 PITR Azure 入口網站

使用 PowerShell 變更 PITR 備份保留期間Change PITR backup retention period using PowerShell

注意

本文已更新為使用新的 Azure PowerShell Az 模組。This article has been updated to use the new Azure PowerShell Az module. AzureRM 模組在至少 2020 年 12 月之前都還會持續收到錯誤 (Bug) 修正,因此您仍然可以持續使用。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要深入了解新的 Az 模組和 AzureRM 的相容性,請參閱新的 Azure PowerShell Az 模組簡介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 如需 Az 模組安裝指示,請參閱安裝 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

重要

Azure SQL Database 仍然支援 PowerShell Azure Resource Manager 模組,但所有未來的開發都是針對 Az .Sql 模組。The PowerShell Azure Resource Manager module is still supported by Azure SQL Database, but all future development is for the Az.Sql module. 如需這些 Cmdlet,請參閱AzureRMFor these cmdlets, see AzureRM.Sql. Az 模組和 AzureRm 模組中命令的引數本質上完全相同。The arguments for the commands in the Az module and in the AzureRm modules are substantially identical.

Set-AzSqlDatabaseBackupShortTermRetentionPolicy -ResourceGroupName resourceGroup -ServerName testserver -DatabaseName testDatabase -RetentionDays 28

使用 REST API 變更 PITR 保留期間Change PITR retention period using REST API

範例要求Sample Request

PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/resourceGroup/providers/Microsoft.Sql/servers/testserver/databases/testDatabase/backupShortTermRetentionPolicies/default?api-version=2017-10-01-preview

要求本文Request Body

{
  "properties":{
    "retentionDays":28
  }
}

範例回應Sample Response

狀態碼:200Status code: 200

{
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Sql/resourceGroups/resourceGroup/servers/testserver/databases/testDatabase/backupShortTermRetentionPolicies/default",
  "name": "default",
  "type": "Microsoft.Sql/resourceGroups/servers/databases/backupShortTermRetentionPolicies",
  "properties": {
    "retentionDays": 28
  }
}

如需詳細資訊,請參閱備份保留 REST APIFor more information, see Backup Retention REST API.

後續步驟Next steps