All Products
Search
Document Center

ApsaraDB RDS:Configure automatic backup

Last Updated:Dec 11, 2024

Automatic backup and manual backup are supported for ApsaraDB RDS for MySQL instances, including serverless ApsaraDB RDS for MySQL instances. 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 more information about how to use the automatic backup feature for an RDS instance that runs a different database engine, see the following topics:

Backup introduction

You can back up your RDS instance by using one of the following methods:

  • ApsaraDB RDS: ApsaraDB RDS provides a default backup feature that supports full data backups and incremental log backups.

  • Database Backup (DBS): DBS provides the logical backup feature. The feature supports advanced capabilities such as cross-account backup, backup of individual databases or tables, cross-region backup, and storage of backup files in an Object Storage Service (OSS) bucket.

For more information about the differences between the default backup feature of ApsaraDB RDS and the logical backup feature of DBS, see Differences between default RDS backups and advanced DBS backups.

Use ApsaraDB RDS to perform automatic backups

ApsaraDB RDS supports automatic data backups and automatic log backups.

  • Data backup: By default, data backup is enabled 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 a large number of data backup files, you can modify the backup frequency and backup retention period to reduce the number of data backup files.

  • Log backup: Log backup is also known as incremental backup. By default, log backup is enabled and can be disabled. Log backup files are retained for at least seven days. You can perform point-in-time recovery (PITR) to restore data at any point in time starting from the point in time when the first full backup within the backup retention period was created based on data backups and log backups. If you do not require a large number of log backup files, you can reduce the backup retention period or disable log backup to reduce the number of log backup files.

You can modify the backup policies based on the Procedure section of this topic. You can also reduce the number of backup files based on the instructions provided in Delete backup files or reduce the size of backup files.

Instance category

Minimum frequency of data backups

Maximum frequency of data backups

  • RDS instances that run RDS High-availability Edition or RDS Enterprise Edition with local disks

  • RDS instances that run RDS Basic Edition with cloud disks

Twice every week

Once every day

RDS instances that run RDS High-availability Edition or RDS Cluster Edition with cloud disks

Once every 15 minutes (You must select Increase Snapshot Frequency.)

Prerequisites

If this is the first time you use the backup feature of ApsaraDB RDS, make sure that the AliyunServiceRoleForDBS service-linked role is created by using your Alibaba Cloud account. For more information, see How do I create a service-linked role for DBS?

Billing rules

If the total size of the backup files of your RDS instance does not exceed the free quota on backup storage, no fees are generated. For more information, see View and manage the size of backup files. 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, see Backup storage fees.

Usage notes

  • If the minor engine version of your RDS instance meets the following conditions, the RDS instance cannot be backed up after it 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.

    Note
  • You can configure only a binary log retention policy for read-only RDS instances. You cannot configure an automatic backup policy for read-only RDS instances. For more information, see Delete the binary log files of an ApsaraDB RDS for MySQL instance.

  • Do not execute DDL statements during a backup. These statements trigger locks on tables, and the backup may fail as a result of the locks.

  • We recommend that you perform backup operations 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 numbers of databases and tables. For more information, see Step 2: Connect to an ApsaraDB RDS for MySQL instance.

  • If the number of tables that are created on your RDS instance exceeds 50,000, you cannot restore individual databases or tables. For more information, see Restore individual databases and tables.

  • After you modify the automatic backup policy for your RDS instance, the system initiates a full backup.

Procedure

In specific regions, you can click Switch to Advanced Backup Policy on the Backup Strategy tab. Then, you can configure advanced settings to perform sparse backups. If the button is not displayed, submit an application. For more information, see Use the sparse backup feature. After you click Switch to Advanced Backup Policy, the entry point to the Backup Strategy tab and the method to configure specific parameters are changed. You must configure the parameters based on your business requirements.

Regular backup (before the switch)

  1. 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.

  2. In the left-side navigation pane, click Backup and Restoration.

  3. On the Backup and Restoration page, click the Backup Strategy tab. In the Basic Backup section, click Edit.

  4. Configure the following parameters and click OK.

    Note

    If your RDS instance uses cloud disks, the system creates snapshots to back up the data of the RDS instance.

    Table 1. Data backup settings

    Instance category

    Setting or parameter

    Description

    All RDS instances

    Backup retention period

    The number of days for which backup files are retained. Default value: 7. Valid values:

    • RDS instances that use cloud disks: 7 to 730.

      Note
      • If your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.

      • If you turn on Backup within Seconds, you can set this parameter to a value that ranges from 7 to 730.

    • RDS instances that use local disks: 7 or more. The value must be less than 2 to the power of 31.

      • Data backup files that are retained for 730 days or less are regular backup files.

      • Data backup files that are retained for more than 730 days are converted into archived backup files. Archived backup files cost less than regular backup files. For more information, see Backup storage fees.

      Note

      If you set this parameter to a value greater than 730 or select Permanently Retained before Instance Release, you must configure the Archived Backups to Retain parameter. For example, if you select Every Month and enter 2 in the field, the system retains the first two archived backup files that are generated each month.

    Backup cycle

    The days on which data backups are performed. You must select at least two days of a week.

    Start At

    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.

    Note
    • We recommend that you set this parameter to Latest or All. After your RDS instance is released, you can go to the Backup for Deleted Instances tab to download the backup files of your RDS instance. Then, you can use the backup files to restore your RDS instance. For more information, see Retain backup files for a long period of time.

    • If your RDS instance uses local disks and runs RDS Enterprise Edition, this parameter is unavailable.

    RDS instances with local disks

    Database/Table Restoration

    Specifies whether to enable the restoration feature for individual databases and tables. If the feature is enabled, you can restore the tables and databases on your RDS instance. For more information, see Restore individual databases and tables. By default, the feature is enabled and cannot be disabled.

    Note

    Fast Restoration

    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. For more information, see Restore individual databases and tables.

    • Standard: Databases and tables are restored at a standard speed.

    • Fast: Databases and tables are restored at a fast speed. Fast restoration provides a restoration speed that is 50% to 95% faster than standard restoration.

    Note
    • If you enable the fast restoration feature for individual databases and tables, you must also configure 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 with cloud disks

    Backup Within Seconds

    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.

    Note

    This feature is supported for RDS instances that run RDS High-availability Edition with Enterprise SSDs (ESSDs) or run RDS Cluster Edition.

    Increase Snapshot Frequency

    The frequency at which snapshot backups are created. This feature enables you to configure a shorter interval to create snapshots by using the single-digit second backup feature, which increases the frequency of the snapshots. You can increase the frequency to up to once every 15 minutes. For more information, see Use the high-frequency snapshot backup feature.

    Note
    • This feature is supported for RDS instances that run RDS High-availability Edition with cloud disks or run RDS Cluster Edition.

    • Before you can use this feature, you must enable the single-digit second backup feature. If the single-digit second backup feature is disabled, the system automatically enables the single-digit second backup feature when you enable the high-frequency snapshot backup feature.

    Fast Restoration

    Specifies whether to enable the fast restoration feature for individual databases and tables. Fast restoration provides a restoration speed that is 50% to 95% faster than standard restoration. For more information, see Restore individual databases and tables.

    Note

    The fast restoration feature for individual databases and tables is supported in specific Alibaba Cloud regions.

    Table 2. Log backup settings

    Log Backup Settings (regular 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. This feature is enabled by default.

    Log Backup Retention Period (Days)

    • The number of days for which log backup files are retained. Valid values: 7 to 730. Default value: 7.

    • The value of this parameter must be less than or equal to the data backup retention period.

    Note

    If your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.

    Configure the PITR feature (advanced log backup)

    The PITR feature is supported for RDS instances that reside in specific regions. For more information about the differences between the PITR and log backup features, the description of the PITR feature, and the requirements to enable the PITR feature, see Configure the PITR feature.

    Important

    To implement PITR, the system retains additional backup sets that are stored longer than the value of the Time Range of Restoration Points parameter.

    For example, if you set the Time Range of Restoration Points parameter to 7, the system retains the backup sets that were generated within 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.

    Note

    If your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.

Advanced backup (after the switch)

  1. 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.

  2. In the left-side navigation pane, click Backup and Restoration.

  3. On the Backup and Restoration page, click the Backup Strategy tab. On the tab that appears, click the circled number between MySQL and Level-1 Backup to view the backup policies that you configured.

    image.png

  4. Configure the following parameters and click OK.

    Table 1. Data backup settings

    Instance category

    Parameter

    Description

    All RDS instances

    Backup Policy

    The backup time and the retention period of the backup sets. Data must be backed up at least twice a week.

    Note

    You can click Add Backup Policy to configure the sparse backup feature. This way, you can configure flexible backup policies and retain the minimum number of backup sets. For more information, see Use the sparse backup feature.

    Start At

    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.

    Note
    • We recommend that you set this parameter to Latest or All. After your RDS instance is released, you can go to the Backup for Deleted Instances tab to download the backup files of your RDS instance. Then, you can use the backup files to restore your RDS instance. For more information, see Retain backup files for a long period of time.

    • If your RDS instance uses local disks and runs RDS Enterprise Edition, this parameter is unavailable.

    RDS instances with local disks

    High-frequency Incremental Backup

    The frequency at which backups are performed. After you enable this feature, the minimum frequency is every 1 hour. For more information, see Use the high-frequency physical backup feature.

    Note

    This feature is supported for RDS instances that run MySQL 5.6, MySQL 5.7, and MySQL 8.0 on RDS High-availability Edition with local disks.

    Backup Encryption Status

    Specifies whether to enable the backup encryption feature. For more information, see Use the backup encryption feature.

    RDS instances with cloud disks

    Backup Within Seconds

    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.

    Note

    This feature is supported for RDS instances that run RDS High-availability Edition with ESSDs or run RDS Cluster Edition.

    Fast Restoration

    Specifies whether to enable the fast restoration feature for individual databases and tables. Fast restoration provides a restoration speed that is 50% to 95% faster than standard restoration. For more information, see Restore individual databases and tables.

    Note

    The 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. This feature is enabled by default.

    Log Backup Retention Period

    The log backup retention period. The log backup retention period must be less than or equal to the data backup retention period. Valid values: 7 to 7300. Unit: days. Default value: 7.

    Note

    If your RDS instance runs MySQL 5.7 on RDS Basic Edition, the value is fixed as 7.

  5. In the lower-left corner of the Backup Strategy tab, click Save.

Use DBS to perform automatic backups

DBS allows you to create and configure a backup schedule by using the logical backup feature to automatically back up an RDS instance or a self-managed MySQL instance. For more information, see Back up an ApsaraDB RDS for MySQL instance or a self-managed MySQL database by using logical backup.

References

  • You can also manually back up all databases or individual databases and tables of an RDS instance. For more information, see Perform a manual backup.

  • You can download existing data backup files or log backup files to your on-premises device for archiving. You can also download backup files and upload the backup files to Object Storage Service (OSS) buckets. For more information, see Download backup files.

  • You can use data backup files and log backup files to restore data to an existing RDS instance, a new RDS instance, or a self-managed MySQL instance. For more information, see Overview of data restoration methods.

  • The backup files that are created by using the automatic backup method are stored in the same region as your RDS instance. If you want to back up your RDS instance to a different region, follow the instructions provided in Use the cross-region backup feature.

  • You can also call the operations to manage the backup policy of an RDS instance or configure a DBS backup schedule. The following table describes the operations.

    Category

    Operation

    Description

    ApsaraDB RDS

    ModifyBackupPolicy

    Modifies the backup settings of an instance.

    DescribeBackupPolicy

    Queries the backup settings of an instance.

    DescribeBackups

    Queries backup sets.

    DescribeBackupTasks

    Queries the backup tasks of an instance.

    DBS

    CreateBackupPlan

    Creates a DBS backup schedule.

    ConfigureBackupPlan

    Configures a DBS backup schedule.

FAQ

  • Does the backup task 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.

    Note

    In rare cases when the secondary instance is unavailable, backups are performed on the primary instance.

    RDS Basic Edition

    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.

  • Can I disable the data backup feature or the log backup feature?

    You cannot disable the data backup feature for your RDS instance. However, you can reduce the data backup frequency to at least twice a week and retain the data backup files for at least 7 days. You can disable the log backup feature for your RDS instance on the Backup Strategy tab.

  • Why does my backup task fail?

    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.

  • Why is the size of a snapshot backup file significantly larger than the amount of data on my RDS instance?

    The size of backup files may not equal the amount of data on your RDS instance. If your RDS instance uses cloud disks, the system creates snapshots to back up your RDS instance. The size of a snapshot backup file may be significantly larger than the amount of data. The free quota on backup storage for an RDS instance that uses cloud disks is 200% of the storage capacity of the RDS instance. The free quota on backup storage for an RDS instance that uses local disks is 50% of the storage capacity of the RDS instance.

    Note

    When 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.

    The total size of all backup sets that is displayed on the Backup and Restoration page in the ApsaraDB RDS console may be inconsistent with the size of used storage resources.