自動備份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 and at no additional charge. 您不需要執行任何動作來建立備份。You don't need to do anything to make them happen. 資料庫備份可保護資料免於意外損毀或刪除,是商務持續性和災害復原策略中不可或缺的一部分。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. 備份會儲存在RA-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

視購買模型和服務層而定,每個 SQL Database 的預設備份保留週期會介於 7 到 35 天。Each SQL Database has a default backup retention period between 7 and 35 days that depends on the purchasing model and service tier. 可以在 SQL 数据库服务器上更新数据库的备份保持期。You can update the backup retention period for a database on SQL Database server. 如需詳細資訊,請參閱變更備份保留週期For more information, see Change Backup Retention Period.

如果您刪除資料庫,則 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.

預設備份保留期限Default backup retention period

以 DTU 為基礎的購買模型DTU-based purchasing model

使用以 DTU 為基礎的購買模型所建立之資料庫的預設保留週期取決於服務層:The default retention period for a database created using the DTU-based purchasing model depends on the service tier:

  • 基本服務層一個週。Basic service tier is one week.
  • 標準服務層五個週。Standard service tier is five weeks.
  • Premium 服務層五個週。Premium service tier is five weeks.

以虛擬核心為基礎的購買模型vCore-based purchasing model

如果您使用虛擬核心為基礎的購買模型,預設的備份保留期限是七個(單一、 集區,及執行個體的資料庫)。If you're using the vCore-based purchasing model, the default backup retention period is seven days (for single, pooled, and instance databases). 針對所有 Azure SQL 資料庫 (單一、集區和執行個體資料庫),您可以將備份保留期限變更為最多 35 天For all Azure SQL databases (single, pooled, and instance databases, you can change backup retention period up to 35 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.

備份發生頻率為何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

根據預設,您資料庫的 7 天自動備份,將會複製到符合 RA-GRS 標準的 Blob 儲存體。Seven days of automated backups of your databases are copied to RA-GRS Standard blob storage by default. 每週完整備份、每日差異備份以及每 5 分鐘複製一次的交易記錄備份都使用此儲存體。The storage is used by weekly full backups, daily differential backups, and transaction log backups copied every 5 minutes. 交易記錄檔的大小取決於資料庫的變動率。The size of the transaction log depends on the rate of change of the database. 會提供等於資料庫大小 100% 的最低儲存空間,且無額外費用。A minimum storage amount equal to 100% of database size is provided at no extra charge. 備份儲存體的額外使用量會按每月每 GB 來收費。Additional consumption of backup storage will be charged in GB/month.

如需儲存體價格的詳細資訊,請參閱定價頁面。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 across the service. 一旦還原,資料庫也會收到使用 DBCC CHECKDB 的完整性檢查。Upon restore, databases also receive integrity checks using DBCC CHECKDB. 在完整性檢查期間找到的任何問題都會對工程小組發出警示。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.

注意

這些 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 the 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.

變更 SQL Database 伺服器的 PITRChange PITR for a SQL Database server

變更 PITR Azure 入口網站

變更受控執行個體的 PITRChange PITR for a Managed Instance

變更 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.

重要

PowerShell Azure 资源管理器模块仍受 Azure SQL 数据库的支持,但所有未来的开发都是针对 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,请参阅 AzureRM.SqlFor 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