This topic describes how to back up an ApsaraDB RDS for MySQL instance. ApsaraDB RDS for MySQL supports both automatic and manual backups. If the data of your RDS instance is lost or corrupted, you can restore the instance by using its backup files. If your RDS instance uses local SSDs, you can also retain its backup files for a specific period of time after you release the instance.

For more information about how to back up RDS instances that run other database engines, see the following topics:

Note This topic describes the default backup function, which stores backup files in the region where your RDS instance resides. You can also store backup files to a different region. For more information, see Back up an ApsaraDB RDS for MySQL instance across regions.

Features

Billing

Each RDS instance is allocated with a free quota for backup storage. If your backup storage usage exceeds the free quota, you must pay for the extra backup storage that you use. We recommend that you specify a proper backup cycle based on your business requirements to maximize the usage of the free backup storage. For more information about the free quota for backup storage, see View the free quota for backup storage of an ApsaraDB RDS for MySQL instance.

After the free quota is exhausted, your backup storage usage is charged based on the specified retention period. For more information about the pricing of regular backup files that are retained for 730 days or less, see the pricing information at ApsaraDB for RDS. For more information about the pricing of archived backup files that are retained for more than 730 days, see Pricing of Long-Term Backup Files on Alibaba Cloud International Site.

Precautions

  • Your RDS instance supports archived backups only when it uses local SSDs.
  • Do not execute data definition language (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 back up your RDS instance during off-peak hours.
  • If the data volume is large, backing up your RDS instance may require a long time.
  • Backup files are retained based on the specified retention period. Before the retention period elapses, we recommend that you download the required backup files to your computer.
  • If the number of tables created on your RDS instance exceeds 50,000, you cannot restore individual databases or tables. For more information, see Restore individual databases and tables of an ApsaraDB RDS for MySQL instance. If the number of tables exceeds 600,000, you cannot back up your RDS instance. In these cases, we recommend that you shard the databases on your RDS instance.

Overview of data and log backups

Data backup Log backup
Data backups are copies of the data in the databases on your RDS instance. These include physical, logical, and snapshot backups. You can use these backups to restore your RDS instance. For more information, see Restore the data of an RDS MySQL instance. Your RDS instance automatically creates physical or snapshot backups based on the storage media that you use:
  • MySQL 5.5, 5.6, 5.7, and 8.0 on RDS High-availability or Enterprise Edition with local SSDs:
    • Support full physical backups when you perform automatic backups.
    • Support full physical backups, full logical backups, and single-database logical backups when you perform manual backups.
  • MySQL 5.7 and 8.0 on RDS High-availability Edition with standard or enhanced SSDs:

    Support only snapshot backups. Snapshot backup files can be used to restore data to a new RDS instance. You cannot download snapshot backup files.

  • MySQL 5.7 and 8.0 on RDS Basic Edition with standard SSDs:

    Support only snapshot backups. Snapshot backup files can be used to restore data to a new RDS instance. You cannot download snapshot backup files.

Log backups are copies of the binary log files that are generated on your RDS instance. Log backup files can be used to restore your RDS instance to a point in time. For more information, see Restore the data of an RDS MySQL instance. Your RDS instance automatically backs up its binary logs.
Note
  • Log backup files occupy disk space on your RDS instance.
  • If a log backup file reaches 500 MB in size or its write operation exceeds 6 hours, your RDS instance starts to write data into a new log backup file. The old log backup file is then asynchronously uploaded to Alibaba Cloud Object Storage Service (OSS).
  • After a log backup file is uploaded to OSS, it no longer occupies disk space on your RDS instance. However, you can still use this log backup file for data restoration.
  • The RDS Basic Edition does not support the upload of log backup files to OSS.
  • You cannot access the OSS buckets that store log backup files.

Modify the backup settings of an RDS instance equipped with local SSDs

ApsaraDB for RDS automatically backs up each RDS instance based on the specified backup policy.

  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where the target RDS instance resides.
    Select a region
  3. Find the target instance and click the instance ID.
  4. In the left-side navigation pane, click Backup and Restoration.
  5. On the Backup and Restoration page, click the Backup Settings tab and then the Edit button.
  6. Configure the following parameters and click OK.
    Modify the backup settings of an RDS instance equipped with local SSDs
    Parameter Description
    Backup Cycle The cycle based on which you want to create a backup. You can select one or more days of the week.
    Note To ensure data security, we recommend that you back up the RDS instance at least twice a week.
    Backup Time The hour at which you want to create a backup. We recommend that you select an off-peak hour.
    Retention Period The period of time for which you want to retain backup files. You can specify a specific number of days or select long term backup.
    • If you specify a specific number of days, the system deletes backup files that are stored longer than the specified retention period. If you select the long term backup option, the system does not delete backup files. If you want to retain backup files after you release the RDS instance, set the Backup Retention Policy After Release parameter to Latest or All.
    • If the specified retention period does not exceed 730 days, backup files are retained as regular backup files.
    • If the specified retention period exceeds 730 days, backup files that are stored longer than 730 days are automatically converted into archived backup files. Therefore, you must also specify an archived backup retention period. For example, if you select Monthly and then specify 2 in the unit field, the system can retain the first two archived backup files that are generated per month.Configure the backup cycle
    Log Backup The switch that is used to enable or disable the log backup function.
    Notice If you disable this function, all of the log backup files are deleted and you cannot restore the RDS instance to a point in time.
    Log Retention Period (Days)
    • The number of days for which you want to retain log backup files. Valid values: 7 to 730. Default value: 7.
    • The log backup retention period must be shorter than or equal to the data backup retention period.
    Restore Individual Database/Table The function that is used to restore individual databases and tables. After you enable this function, the system changes the backup file format to support this function. By default, this function is enabled and cannot be disabled. For more information, see Restore individual databases and tables of an ApsaraDB RDS for MySQL instance.
    Backup Retention Policy After Release The policy that is used to retain data backup files after the RDS instance is released. Valid values: None, Latest, and All.

    To prevent data losses caused by overdue payments or unintentional operations, we recommend that you select Latest or All.

Modify the backup settings of an RDS instance equipped with standard or enhanced SSDs

ApsaraDB for RDS automatically backs up each RDS instance based on the specified backup policy.

  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where the target RDS instance resides.
    Select a region
  3. Find the target instance and click the instance ID.
  4. In the left-side navigation pane, click Backup and Restoration.
  5. On the Backup and Restoration page, click the Backup Settings tab and then the Edit button.
  6. Configure the following parameters and click OK.
    Modify the backup settings of an RDS instance equipped with standard or enhanced SSDs
    Parameter Description
    Snapshot Backup Period The cycle based on which you want to create a backup. You can select one or more days of the week.
    Note To ensure data security, we recommend that you back up the RDS instance at least twice a week.
    Snapshot Backup Start Time The hour at which you want to create a backup. We recommend that you select an off-peak hour.

    If you want to increase the snapshot backup frequency, select Increase Snapshot Frequency and specify a snapshot backup frequency.

    Snapshot Backup Retention The number of days for which you want to retain snapshot backup files. The maximum snapshot backup retention period is 730 days. However, if you select Increase Snapshot Frequency, the maximum snapshot backup retention period is shortened based on the specified snapshot backup frequency. You can calculate the maximum snapshot backup retention period based on the following formula:

    Maximum snapshot backup retention period = ⌊900/Number of backups created per day/Number of backups created per week × 7⌋ (rounded down to the next integer)

    For example, if you select two days of the week and then specify the Every 30 Minutes frequency, the maximum snapshot backup retention period is 65 days based on the following calculation: Maximum snapshot backup retention period = ⌊900/(24 × 2 )/2 × 7⌋ = 65 (days).

    Log Backup The switch that is used to enable or disable the log backup function.
    Notice If you disable this function, all of the log backup files are deleted and you cannot restore the RDS instance to a point in time.
    Log Retention Period (Days)
    • The number of days for which you want to retain log backup files. Valid values: 7 to 730. Default value: 7.
    • The log backup retention period must be shorter than or equal to the data backup retention period.
    Note If the RDS instance runs MySQL 5.7 on RDS Basic Edition with standard SSDs, the log retention period is seven days and cannot be changed.
    Single-digit Second Backup The switch that is used to enable the single-digit second backup function. This function allows you to take snapshots in seconds. ApsaraDB for RDS retains up to 10 snapshot backup files. If the number of retained snapshot backup files reaches 10, the next snapshot backup will fail. Therefore, we recommend that you set the Snapshot Backup Retention parameter to a value that is less than or equal to 10.
    Note This function is supported only when the RDS instance uses enhanced SSDs.

Manually back up an RDS instance

In this example, the RDS instance runs MySQL 5.7 on RDS High-availability Edition with local SSDs.

  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where the target RDS instance resides.
    Select a region
  3. Find the target instance and click the instance ID.
  4. In the upper-right corner of the page, click Back Up Instance.
  5. Specify a backup mode and a backup policy. Then, click OK.
    Physical backup
    Note If you select the Logical Backup mode and then the Single-Database Backup policy, you must also select databases from the left-side list and click the > icon to add the selected databases to the right-side list. If no databases are available, you must create databases before a backup. For more information, see Create databases and accounts for an ApsaraDB RDS MySQL instance.
    Single-database logical backup
  6. In the upper-right corner of the page, click the Task Progress icon to view the progress of the backup task.
    View the progress of the backup task
    Note
    • After the backup task is complete, you can go to the Backup and Restoration page to download the backup file. Some RDS instances do not support the download of backup files. For more information, see Download data and log backup files of an ApsaraDB RDS for MySQL instance.Download a backup file
    • The retention period of backup files that are generated from manual backups is specified by the Data Backup Retention parameter. For more information, see the parameters described in Step 6.

FAQ

  1. Can I disable the data backup function of my RDS instance?

    No, you cannot disable the data backup function of your RDS instance. However, you can reduce the backup frequency to as low as twice a week. The data backup retention period must be at least seven days.

  2. Can I disable the log backup function of my RDS instance?

    Yes, you can disable the log backup function of your RDS instance if you are not using the RDS Basic Edition.

  3. Why did my backup task fail?

    You may have executed DDL statements when the backup task was in progress. DDL statements trigger locks on tables. Your backup task may have failed as a result of the table locks.

  4. Why does my RDS instance have a small volume of data but the generated snapshot is large in size?

    When creating a single snapshot, the system eliminates empty blocks. This allows the size of the snapshot to be smaller than the required disk space. Each block is 2 MB in size. However, if write operations are dispersed, a large number of blocks are not full. For example, 3 MB of data may be written into two, three, or four blocks, and none of these blocks is full. When calculating the size of the snapshot, the system considers all of these non-empty blocks to which data is written. As a result, the disk space occupied by the snapshot is greater than the actual size of the snapshot.

  5. After I release my RDS instance, how do I restore data by using a retained backup file?

    Log on to the ApsaraDB for RDS console and navigate to the Backup for Deleted Instances page. Then, download the required backup file and restore data to an on-premises database.

    Backup for Deleted Instances

References

Related operations

Operation Description
Create backup set Creates a data backup for an ApsaraDB for RDS instance.
Query backup sets Queries the data backup files of an ApsaraDB for RDS instance.
Query backup settings Queries the backup settings of an ApsaraDB for RDS instance.
Modify backup settings Modifies the backup settings of an ApsaraDB for RDS instance.
Delete backup sets Deletes one or more data backup files from an ApsaraDB for RDS instance.
Query backup tasks Queries the backup tasks of an ApsaraDB for RDS instance.
Query binary logs Queries the log backup files of an ApsaraDB for RDS instance.