ApsaraDB RDS for MySQL or Serverless ApsaraDB RDS for MySQL instances support automatic backup. This topic describes how to configure a backup policy to automatically back up the data and logs of an RDS instance at regular intervals.
For other engines, see the following:
Backup introduction
You can back up your RDS instance by using one of the following methods:
Use ApsaraDB RDS to perform automatic backups: ApsaraDB RDS automatically performs full (data) backups and incremental (log) backups.
Use Data Disaster Recovery to perform backups: Data Disaster Recovery performs logical backups and provides advanced backup features. These features include cross-account backup, backup of individual databases or tables, geo-redundancy, and backup storage in OSS.
For more information about the differences between these two backup methods, see Differences between default backup and Data Disaster Recovery.
Use ApsaraDB RDS to perform automatic backups
ApsaraDB RDS supports automatic data backups and automatic log backups.
Data backup: This feature is enabled by default and cannot be disabled. Data backup files are retained for at least seven days. Data must be backed up at least twice each week. If you do not require many data backup files, you can modify the backup frequency and backup retention period to reduce the number of data backup files.
Log backup: This feature is also called incremental backup. This feature is enabled by default and can be disabled. Log backup files are retained for at least seven days. Based on data backups and log backups, you can restore the data of your RDS instance to a point in time (PITR) after the first full backup within the backup retention period. If you do not require many log backup files, you can reduce the backup retention period or disable log backup to reduce the number of log backup files.
You can refer to the Procedure section in this topic to modify the backup policy of your RDS instance, or refer to the Delete or reduce backups tutorial to reduce the number of backups for your ApsaraDB RDS for MySQL instance.
Instance type | Minimum backup frequency | Maximum backup frequency |
High-performance instances that use local disks (RDS High-availability Edition or RDS Enterprise Edition) | Twice every week | Once every day |
Cloud disk instance (Basic Edition) | Once every day | |
RDS instances that run RDS High-availability Edition or RDS Cluster Edition with cloud disks | Once every 15 minutes (if you enable Increase Snapshot Frequency) |
Prerequisites
If you use the ApsaraDB RDS backup service for the first time, you must use your Alibaba Cloud account to complete the Service-linked Role authorization for Data Disaster Recovery (AliyunServiceRoleForDBS).
Billing
If the total size of the backup files does not exceed the free quota, you are not charged for the backup storage. If the total size of the backup files exceeds the free quota on backup storage, you are charged for the excess storage usage based on the pay-as-you-go billing method. For more information about the billing standards, see Backup fees.
Precautions
If your RDS instance runs one of the following minor engine versions, you cannot create backups after the RDS instance is locked.
Any minor engine version if the RDS instance runs MySQL 5.1 or MySQL 5.5.
20190815 or earlier if the RDS instance runs MySQL 5.6, MySQL 5.7, or MySQL 8.0.
NoteIf you want to upgrade the major engine version or minor engine version of your RDS instance, see Upgrade the database engine version of an ApsaraDB RDS for MySQL instance or Upgrade the minor engine version of an ApsaraDB RDS for MySQL instance.
For more information, see Resolve the issue that the status of an ApsaraDB RDS for MySQL instance is Locked.
For read-only RDS instances, you can configure only the local log retention policy. You cannot configure an automatic backup policy.
Do not execute DDL statements during a backup operation. If DDL statements are executed during a backup operation, the relevant tables are locked and the backup operation fails.
We recommend that you back up your RDS instance during off-peak hours.
If the number of tables that are created on your RDS instance exceeds 600,000, backups cannot be created. In this case, we recommend that you shard the databases on your RDS instance. You can log on to your RDS instance to view the number of databases and tables.
If the number of tables that are backed up exceeds 50,000, you cannot restore individual databases or tables.
After you modify the automatic backup policy for your RDS instance, the system initiates a full backup.
Procedure
In some Alibaba Cloud regions, you can upgrade the backup policy page to the advanced version (If no upgrade entry is available, submit an application to use the feature). After the upgrade, you can implement sparse backup. After you enable the advanced backup settings, the entry point to configure backup policies and the method to configure some parameters are changed. You must configure the backup policies and parameters based on your business requirements.
If you modify the backup policy during a specification change, the modification may fail. We recommend that you wait until the specification change is complete before you modify the backup policy.
Standard backup policy page (not upgraded)
Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
In the left-side navigation pane, click Backup and Restoration.
On the Backup and Restoration page, click the Backup Strategy tab. In the Basic Backup section, click Edit.
Configure the following parameters and click OK.
NoteIf your RDS instance uses cloud disks, ApsaraDB RDS creates snapshots to back up the data of the RDS instance.
Table 1. Data backup settings
Instance type
Parameter
Description
All instances
Data Backup Retention (Days)
The number of days for which data backup files are retained. Default value: 7. Valid values:
For RDS instances that use cloud disks: 7 to 730.
NoteIf your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.
If you enable Single-digit Second Backup, the valid value ranges from 7 to 730.
For high-performance instances that use local disks: 7 or more (less than 2^31).
Data backup files that are retained for 730 days or less are considered regular backup files.
Data backup files that are retained for more than 730 days are considered archived backup files. The fees for archived backup files are lower than those for regular backup files.
NoteIf you set the retention period to more than 730 days or select Long-term Retention Before Instance Release, you must also specify the number of archived backup files to retain. For example, you can retain the earliest two archived backup files of each month.
Backup Cycle
The days on which data is backed up. You must select at least two days of the week.
Backup Start Time
The time at which a data backup starts. For example, you can select 08:00. We recommend that you select an off-peak hour.
Retain Backup Files After Instance Release
Specifies whether to retain backup files after the RDS instance is released.
NoteWe recommend that you select Retain The Last Backup or Retain All. After the RDS instance is released, you can download the backup files from the Deleted Instances page to restore data. For more information, see Method 2: Configure the backup file retention policy for released instances.
If your RDS instance uses local disks and runs RDS Enterprise Edition, this parameter is unavailable.
High-performance instances that use local disks
Restore Individual Database/Table
Specifies whether to enable the feature to restore individual databases and tables. By default, the feature is enabled and cannot be disabled.
NoteThis feature is supported only for RDS instances that run MySQL 8.0, 5.7, or 5.6 on RDS High-availability Edition with local SSDs.
After you enable this feature, the system gradually uses a new physical backup format to create backup files.
Fast Restoration For Individual Databases And Tables
Specifies whether to enable the fast restoration feature for individual databases and tables. If you enable the feature, the data is restored at a fast speed. If you disable the feature, the data is restored at a standard speed.
Standard: The data is restored at a standard speed.
Fast: The data is restored at a speed that is 50% to 95% faster than the standard speed.
NoteAfter you enable the fast restoration feature for individual databases and tables, you must also specify the CDM Billing Method and CDM Retention Period parameters.
The fast restoration feature for individual databases and tables is supported in specific Alibaba Cloud regions.
RDS instances that use cloud disks
Single-digit Second Backup
Specifies whether to enable the single-digit second backup feature. If the feature is enabled, a snapshot backup can be completed within a few seconds.
NoteThis feature is supported only for RDS instances that run RDS High-availability Edition or RDS Cluster Edition.
Increase Snapshot Frequency
If you enable the high-frequency snapshot backup feature, you can shorten the interval between consecutive snapshot backups and increase the density of snapshot backups. You can increase the frequency to up to once every 15 minutes.
NoteThis feature is supported only for RDS instances that run RDS High-availability Edition or RDS Cluster Edition.
This feature must be enabled together with the Single-digit Second Backup feature. If you enable this feature when the Single-digit Second Backup feature is disabled, the system automatically enables the Single-digit Second Backup feature.
Fast Restoration For Individual Databases And Tables
If you enable the fast restoration feature for individual databases and tables, the data is restored at a speed that is 50% to 95% faster than the standard speed.
NoteThe fast restoration feature for individual databases and tables is supported in specific Alibaba Cloud regions.
Table 2. Log backup settings
Log backup settings (standard version of log backup)
Parameter
Description
Log Backup
Specifies whether to enable the log backup feature. After this feature is enabled, you can restore the data of your RDS instance to a point in time. By default, the Log Backup feature is enabled.
Log Backup Retention (Days)
Valid values: 7 to 730. Default value: 7.
The value of this parameter must be less than or equal to the value of the Data Backup Retention (Days) parameter.
NoteIf your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.
Point-in-time recovery settings (advanced version of log backup)
This setting is supported only for ApsaraDB RDS for MySQL instances in specific Alibaba Cloud regions. For more information about the differences between point-in-time recovery and log backup, the point-in-time recovery feature, and the requirements for instances that support this feature, see Configure a point-in-time recovery policy.
ImportantTo allow you to restore data to a point in time, the system retains some backup sets for a period that is longer than the value of the Time Range Of Specific Points In Time For Restoration parameter.
For example, if you set the Time Range Of Specific Points In Time For Restoration parameter to 7, the system retains backup data for 7 to 9 days. The system also retains the latest full backup that was created before the seventh day to which you can restore data and all consecutive log backups that were generated from the day on which the latest full backup was created to the seventh day to which you can restore the data. You are charged for the resources that are used to store one full backup and additional log backups generated within one week at most.
Parameter
Description
Restoration to Specific Point in Time
Specifies whether to enable the PITR feature. After the feature is enabled, you can restore the data of your RDS instance to any point in time. The feature is an enhancement of the log backup feature. By default, Time Range of Specific Points in Time for Restoration is turned on for new RDS instances.
Time Range of Specific Points in Time for Restoration
The number of days during which you can restore data of your RDS instance to any point in time. If the value of this parameter is modified, the retention period of log backups is also modified.
Valid values: 7 to 730. Default value: 7.
The value must be less than or equal to the retention period of full backups.
NoteIf your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.
Advanced backup policy page (upgraded)
Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
In the left-side navigation pane, click Backup and Restoration.
On the Backup and Restoration page, click the Backup Strategy tab, and then click the circled number between MySQL and Primary Backup.
Configure the following parameters and click OK.
Table 1. Data backup settings
Instance type
Parameter
Description
All instances
Backup Policy
The backup time and the retention period of the backup sets. Data must be backed up at least twice a week.
NoteYou can click the Add Backup Policy button to configure the sparse backup feature. This feature allows you to flexibly configure backup policies and retain the minimum number of backup sets. For more information, see Sparse backup.
Backup Start Time
The time at which a data backup starts. For example, you can select 08:00. We recommend that you back up data during off-peak hours.
Retain Backup Files After Instance Release
Specifies whether to retain backup files after the RDS instance is released.
NoteWe recommend that you select Retain The Last Backup or Retain All. After the RDS instance is released, you can download the backup files from the Deleted Instances page to restore data. For more information, see Method 2: Configure the backup file retention policy for released instances.
If your RDS instance uses local disks and runs RDS Enterprise Edition, this parameter is unavailable.
High-performance instances that use local disks
High-frequency Incremental Backup
After you enable the high-frequency physical backup feature, you can back up data once every hour at the fastest.
NoteThis feature is supported only for RDS instances that run MySQL 5.6, 5.7, or 8.0 on RDS High-availability Edition with local SSDs.
Backup Encryption Status
Specifies whether to enable the backup encryption feature.
RDS instances that use cloud disks
Single-digit Second Backup
Specifies whether to enable the single-digit second backup feature. After the feature is enabled, a snapshot backup can be completed within a few seconds.
NoteThis feature is supported only for RDS instances that run RDS High-availability Edition or RDS Cluster Edition.
Fast Restoration For Individual Databases And Tables
If you enable the fast restoration feature for individual databases and tables, the data is restored at a speed that is 50% to 95% faster than the standard speed.
NoteThe fast restoration feature for individual databases and tables is supported in specific Alibaba Cloud regions.
Table 2. Log backup settings
Parameter
Description
Log Backup
Specifies whether to enable the log backup feature. After this feature is enabled, you can restore the data of your RDS instance to a point in time. By default, the Log Backup feature is enabled.
Log Backup Retention (Days)
The log backup retention period must be less than or equal to the data backup retention period. Valid values: 7 to 7300. Default value: 7.
NoteIf your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.
Click Save in the lower-left corner of the Backup Strategy page.
Use Data Disaster Recovery to perform backups
The Data Disaster Recovery service allows you to create and configure a backup schedule (logical backup) to automatically back up an ApsaraDB RDS for MySQL instance or a self-managed MySQL database.
Related operations
In addition to the automatic backup feature described in this topic, ApsaraDB RDS also allows you to manually back up all databases or specific databases and tables.
You can download backup files to your computer or upload the backup files to OSS.
You can use data restoration solutions to restore data from data backup files and log backup files to an existing RDS instance, a new RDS instance, or a self-managed database.
By default, backup files are stored in the region where the instance is located. If you need to back up to other regions, see cross-region backup.
You can use API operations to manage the backup policy of an RDS instance or configure a backup schedule for Data Disaster Recovery. The following table describes the API operations.
Category
API
Description
Default backup of ApsaraDB RDS
Modifies the backup settings of an ApsaraDB RDS instance.
Queries the backup settings of an ApsaraDB RDS instance.
Queries a list of backup sets.
Queries the backup tasks of an ApsaraDB RDS instance.
Data Disaster Recovery
Creates a backup schedule.
Configures a backup schedule.
FAQ about default backup of ApsaraDB RDS
Q: Do backup operations affect the performance of my RDS instance?
RDS edition
Impact
RDS High-availability Edition, RDS Cluster Edition, or RDS Enterprise Edition
Backup operations are performed on the secondary RDS instance. In this case, the operations do not occupy the CPU resources or affect the performance of the primary RDS instance.
NoteIn rare cases when the secondary instance is unavailable, backups are performed on the primary instance.
If an RDS instance runs RDS Basic Edition, the instance stands alone. All backup operations are performed on the RDS instance. In this case, the performance of the RDS instance decreases during a backup.
Q: Can I disable data backup or log backup?
A: You cannot disable data backup. However, you can reduce the backup frequency to a minimum of twice a week and the retention period to a minimum of seven days. You can disable log backup on the Backup Strategy tab.
Q: If my pay-as-you-go RDS instance has overdue payments, can the automatic backup feature still work?
A: Within the grace period (within seven days after the payment becomes overdue), the automatic backup feature continues to work. After the grace period ends, Alibaba Cloud suspends the RDS instance and stops charging you for the RDS instance. In this case, the automatic backup feature immediately stops working. For more information, see Overdue payments.
Q: Why do backup tasks sometimes fail?
A: You executed time-consuming DDL statements or UPDATE statements during a backup task. These statements triggered locks on tables, and your backup task failed as a result of the locks.
Q: Why is the size of a snapshot backup file dozens of GB when the data size is only a few GB?
A: The size of a backup file can be larger or smaller than the data size.If your RDS instance uses cloud disks, ApsaraDB RDS creates snapshots to back up the data of the RDS instance. The size of a snapshot backup file can be much larger than the data size. The free quota on backup storage is 200% of the storage capacity for RDS instances that use cloud disks and 50% of the storage capacity for high-performance instances that use local disks.
NoteWhen the system calculates the size of a snapshot backup file, the system counts in all the non-empty blocks to which data is written. If the write operations are scattered among blocks, none of the blocks is empty. For example, if 3 MB of data is written across two, three, or four blocks, none of these blocks is empty. In this case, the system counts in all these blocks to calculate the total size. As a result, the size of the snapshot backup file is larger than the actual amount of data.
Therefore, the total backup size of all backup sets displayed on the Backup and Restoration page of the console may differ from the displayed backup usage.
Q: Do database backup files occupy instance disk space?
A: Data backup and log backup are stored in the backup space provided by Alibaba Cloud, which does not occupy the storage space of the instance.
NoteThe backup storage is inaccessible. For information about how to download backup files, see Download the backup files of an ApsaraDB RDS for MySQL instance.
Each RDS instance is allocated a free quota for backup storage. If your backup storage usage exceeds the free quota, you are charged additional fees. For more information, see Billable items and pricing for the backup storage of an ApsaraDB RDS for MySQL instance.