This topic describes how to download the backup files of an ApsaraDB RDS for MySQL instance.

For more information about how to download the backup files of an RDS instance that runs a different database engine, see the following topics:

Before you begin

Before you download the backup files of your RDS instance, you must select a download method based on your business scenario.
Note The data of the backup files that you download cannot be directly restored to your RDS instance. For more information, see Overview of data restoration methods.
Scenario Recommended download method
  • Migrate the data of your RDS instance to another RDS instance or to a self-managed MySQL instance.
  • Restore the data of your RDS instance from a backup file.
Use one of the following methods:
  • Query the data that exists in your RDS instance at a specific point in time.
  • Query the data of a backup file of your RDS instance.
Use one of the following methods:
  • Restore the backup file to a new pay-as-you-go RDS instance. After the query is complete, release the pay-as-you-go RDS instance. For more information about how to restore data, see Restore the data of an ApsaraDB RDS for MySQL instance.
  • Download the backup file, restore the backup file to a self-managed MySQL instance, and then query the data from the self-managed MySQL instance based on the descriptions in this topic.
  • If the backup file is generated by Database Backup (DBS), query data from the backup file. In this case, you do not need to restore data. For more information, see Query data in a single backup set.
  • Save the backup file of your RDS instance to your computer.
  • Download the backup file of your RDS instance and use the backup file for auditing.
Use one of the following methods:
  • Upload the backup file of your RDS instance to an Object Storage Service (OSS) bucket.
Backup files do not consume the storage capacity of your RDS instance. Backup files are stored in the provisioned backup storage and cannot be moved. You can use one of the following methods to store the backup file of your RDS instance in an OSS bucket:
  • Use DBS to back up your RDS instance. Make sure that you select an OSS bucket as your storage. For more information, see Configure a backup schedule.
  • Download the backup file and upload it to the specified OSS bucket based on the descriptions in this topic.
  • Retain the backup files of your RDS instance for a long period of time.
  • Configure DBS to automatically download the backup files of your RDS instance.

Billing rules

  • ApsaraDB RDS provides a free quota for backup downloads over the Internet. Starting from 00:00 on November 25, 2021, you are charged for the excess traffic that you consume to download backup files over the Internet. For more information, see [Notice] Upgrade and commercial release of the backup download feature.
    • Downloads over an internal network: You are not charged for the traffic that you consume.
    • Downloads over the Internet: After the free quota is exhausted, you are charged a daily fee for the excess traffic that you consume. For more information, see Billing overview.
    • Free quota for backup downloads over the Internet: The free quota for each RDS instance is 500 GB per month.
  • You are charged if you convert the backup files of your RDS instances. This applies only when you perform advanced downloads. The advanced download feature is in public preview. In the public preview phase, advanced downloads are free of charge.
Note

To view the volume of traffic that you consumed to download backup files over the Internet, you can log on to the ApsaraDB RDS console, click the ID of your RDS instance to go to the Basic Information page, and then view the Backup Downloads parameter in the Usage Statistics section of the page.

Advanced download

You can create an advanced download task by point in time or backup file. You can set the Download Destination parameter to URL or directly upload the downloaded data to your Object Storage Service (OSS) bucket to facilitate data analysis and offline archiving.

Prerequisites
  • Your RDS instance runs one of the following MySQL versions and storage types:
    • MySQL 8.0 with standard SSDs or enhanced SSDs (ESSDs)
    • MySQL 5.7 with standard SSDs or ESSDs
  • Your RDS instance resides in one of the following regions: China (Guangzhou), China (Qingdao), China (Beijing), China (Shanghai), China (Zhangjiakou), China (Hangzhou), China (Shenzhen), China (Hong Kong), Malaysia (Kuala Lumpur), Indonesia (Jakarta), Japan (Tokyo), Singapore (Singapore), US (Silicon Valley), and US (Virginia).
    Note The feature will be available in the other regions soon.
  • The minor engine version of your RDS instance is later than 20201031. For more information about how to update the minor engine version of an RDS instance, see Update the minor engine version of an ApsaraDB RDS for MySQL instance.
  • The disk encryption feature is disabled for your RDS instance. RDS instances for which disk encryption is enabled do not support advanced downloads.
  • The Resource Access Management (RAM) user that you want to use to log on to your RDS instance is granted the permissions to download backup files. For more information about how to grant permissions to a RAM user, see Grant backup file download permissions to a RAM user with read-only permissions.

    RAM user permissions

    The authentication capability of the advanced download feature is provided based on the policy management feature of RAM. You can attach a policy to the RAM user to allow the RAM user to obtain the download URLs.
    • If you cannot use the advanced download feature, such as creating and querying advanced download tasks, check whether the AliyunDBSFullAccess policy is attached to the RAM user that you use. For more information, see Grant permissions to a RAM user.
    • If you want to use the RAM user to use Database Backup (DBS) but want to prohibit the RAM user from obtaining URLs for advanced downloads, you can create a custom policy to prohibit the RAM user from obtaining URLs for advanced downloads. For more information, see Create a custom policy.
      {
          "Version": "1",
          "Statement": [
              {
                  "Effect": "Deny",
                  "Action": "dbs:DescribeDownloadBackupsetStorageInfo",
                  "Resource": "*"
              }
          ]
      }

      After the custom policy is created, you must attach the custom policy to the RAM user. For more information, see Grant permissions to a RAM user. Then, the RAM user cannot obtain the download URLs for advanced downloads.

Note The advanced download feature is in public preview. In the public preview phase, you can convert the backup files of your RDS instance free of charge. For more information, see Billing rules. In the public preview phase, the versions of RDS instances that are supported by the advanced download feature and the formats of files that are downloaded by using the advanced download feature may be adjusted and optimized. In addition, the limits of the advanced download feature may also be adjusted.

Limits

  • The advanced download feature allows you to export most information about schemas.
    • You can export column information, primary key indexes, non-primary key indexes, unique indexes, partitioned table information, table engines, and table-level or database-level character sets and character collations.
    • You cannot export expression indexes, foreign keys, generated columns, hidden columns, views, functions, stored procedures, system variables, or triggers.
  • The advanced download feature does not support fields of spatial data types. If your RDS instance contains fields of the following spatial data types, file conversions fail:

    GEOMETRY, POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, and GEOMETRYCOLLECTION

  • The CSV files that you export from your RDS instance do not contain the following system libraries:

    information_schema, mysql, performance_schema, sys, and __recycle_bin__

  • If you set the Download Destination parameter to OSS, only the Standard storage class is supported. For more information about how to change storage classes, see Convert storage classes.

Procedure

  1. Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
  2. In the left-side navigation pane, click Backup and Restoration.
  3. On the Data Backup tab of the page that appears, find the backup file that you want to download and click Download Instance Backup in the Actions column.
    Note By default, the ApsaraDB RDS console displays the backup files that were generated over the most recent eight days. If you want to view the backup files that were generated eight days ago, you must change the time range to query.
  4. In the Select Download Mode step of the wizard, select Download by Time or Download by Backup Set and click Next.
    Note The Download by Time option is available only when the log backup feature is enabled for your RDS instance. For more information about how to enable the log backup feature, see Enable or disable the log backup feature.
  5. In the Select Download Content step of the wizard, click Next.
    Note Download Instances is selected by default.
  6. In the Select Download Destination and Format step of the wizard, configure the Download Destination and Download Format parameters and click Complete.
    • Set the Download Destination parameter to URL.
    • Set the Download Destination parameter to OSS.
      1. Select I have learnt that access permissions on the data downloaded to OSS are automatically granted.
      2. Configure the Select Bucket and Directory Prefix parameters.
    Note
    • You can set the Download Format parameter to CSV, SQL, or Parquet.
    • If you do not have the permissions to access OSS resources, follow the instructions in the console and click Authorize and then Confirm Authorization Policy. After the permissions are granted, configure the parameters for the advanced download task.
  7. The Backup Download tab appears.
    • If the Download Destination parameter is set to OSS and the Status parameter of the task changes from Running to Finished, the download is successful. You can view and use the downloaded file in the specified OSS bucket.
    • If the Download Destination parameter is set to URL, perform the following steps after the Status parameter of the advanced download task changes to Finished:
      1. Click Generate Link in the Download Destination column.
      2. Configure the Validity Period parameter and click Generate Link. Then, you can download backup data by using the generated URL.
        Note
        • The validity period of the URL ranges from 5 minutes to 1 day. The default validity period is 2 hours.
        • A download URL is generated based on the validity period that you specify. We recommend that you save the URL at the earliest opportunity and keep the URL confidential.
        • If you use a third-party download tool to download the backup file, additional download traffic may be generated. As a result, you may be charged additional fees. Proceed with caution.
        • For more information about how to download a backup file, see Appendix: Download commands.
        • When you perform an advanced download, you are charged a file conversion fee and a traffic consumption fee. In the public preview phase, file conversions and traffic that is consumed to download backup files over internal networks are free of charge. However, you are charged for the traffic that is consumed to download backup files over the Internet. For more information about the fees for Internet traffic, see Billing rules.
        • You can restore the data to a self-managed MySQL instance by using the downloaded backup file. For more information, see Restore the data of an ApsaraDB RDS for MySQL instance to a self-managed MySQL instance by using a CSV file.

(Optional) What to do next

If you want to query and analyze the data of your RDS instance, use the advanced download feature to download the data to an OSS bucket and then import the data from the OSS bucket to an AnalyticDB for MySQL instance. For more information, see Advanced download and Import data of an ApsaraDB RDS for MySQL instance that uses standard SSDs or ESSDs to an AnalyticDB for MySQL instance.

Standard download

Prerequisites

Procedure

  1. Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
  2. In the left-side navigation pane, click Backup and Restoration.
  3. Click the Data Backup tab or the Log Backup tab.
  4. Select a time range. This step is required if you want to view the backup files that are generated eight days ago. The default time range spans the most recent eight days.
  5. Find the backup file that you want to download. In the Actions column, click Download Instance Backup (on the Data Backup tab) or Download (on the Log Backup tab).
    • After you click Download Instance Backup on the Data Backup tab, you are directed to the Standard Download tab. On the Standard Download tab, you can copy the internal or external URL or click Download over Internet to download the data backup file.
      Notice
      • If you use the internal URL to download the data backup file, make sure that the server to which you log on and the RDS instance reside in virtual private clouds (VPCs) in the same region. If the server and the RDS instance reside in VPCs of different regions or if the server resides in the classic network while the RDS instance resides in a VPC, you cannot download the data backup file by using the internal URL on the server.
      • I have learnt the billing rules for backup file download. is selected by default. If you use the external URL to download the log backup file, you are charged for the excess Internet traffic that you consume. For more information, see Billing rules.
      • For more information about how to download data backup files by using URLs, see Appendix: Download commands.
      • The download URLs are valid for only one hour. If the download URLs expire, you can refresh the page to obtain the latest download URLs.
    • After you click Download on the Log Backup tab, you can click Download or copy the internal or external URL in the dialog box that appears to download the log backup file.
      • Copy Internal URL: If your VPC-type Elastic Compute Service (ECS) instance can communicate with the RDS instance over an internal network, you can log on to your ECS instance and use the internal URL to download the log backup file. This method is faster and more secure.
      • Copy Public URL: If the RDS instance cannot be connected over an internal network, you can use the public URL to download the log backup file.
      Notice
      • The download URLs are valid for only one hour. If the download URLs expire, you can refresh the page to obtain the latest download URLs.
      • If you want to use the log backup file to restore the data of the RDS instance to a self-managed MySQL instance, the point in time at which the used data backup file is generated must be within the restorable time range that is supported by the log backup file. In addition, the log backup file and the data backup file must have the same instance ID.
      • If the RDS instance runs RDS High-availability Edition or RDS Enterprise Edition, both the primary RDS instance and the secondary RDS instances generate log backup files. You can view the IDs of the primary RDS instance and the secondary RDS instances on the Service Availability page.
      • The log backup files that are described in this section are the log backup files that are stored on the RDS instance. For more information about how to obtain these log files, see How do I use the mysqlbinlog command to view the binary logs of an ApsaraDB RDS for MySQL instance?
      • If you use the internal URL to download the log backup file, make sure that the server to which you log on and the RDS instance reside in the same VPC. If the server and the RDS instance reside in VPCs of different regions or if the server resides in the classic network while the RDS instance resides in a VPC, you cannot download the log backup file by using the internal URL on the server.
      • I have learnt the billing rules for backup file download. is selected by default. If you use the external URL to download the log backup file, you are charged for the excess Internet traffic that you consume. For more information, see Billing rules.

Appendix: Download commands

This section describes the commands that are commonly used to download backup files.

Note
  • If the speed of a download is lower than 64 KB per second, the download may be interrupted. When you download a backup file, we recommend that you ensure optimal network status.
  • If you want to download a backup file to a disk that is attached by using ossfs, you must adjust the value of the multipart_size parameter for ossfs. The maximum value of this parameter is 100 GB. If the size of the backup file that you want to download exceeds 100 GB, the download fails. For more information about ossfs and its parameter settings, see Overview and Common options.
  • We recommend that you use the commands, such as wget and curl, that are provided in this topic to download a backup file. If you use a third-party tool to download a backup file, the backup file may be downloaded multiple times. As a result, the amount of data that is downloaded is greater than the size of the backup file, and you may be charged for the traffic that is consumed to download the excess amount of data over the Internet.

Command: nohup wget -c -t 0 "The URL that is used to download the backup file" -O The save path and name of the backup file that you want to download> The file to which the downloaded data is saved &

Example: nohup wget -c -t 0 "https://example.aliyundoc.com/examplebackup.qp.xb" -O /backup/examplebackup.qp.xb > /tmp/download.log &

The following list describes the options in the preceding command:

  • -t 0: enables an unlimited number of retries.
  • -c: enables resumable uploads.
  • -O: specifies the save path and name of the backup file that you want to download.
  • nohup: prevents interruptions to the download and specifies that the process automatically exits after the download is complete. If you accidentally replicate data or disconnect your database client during the download, the download is interrupted.

Command: nohup curl -C - --retry 10 "The URL that is used to download the backup file" -o The user-defined name of the backup file> The file to which the downloaded data is saved &

Example: nohup curl -C --retry 10 "https://example.aliyundoc.com/examplebackup.qp.xb" -o backup.qp.xb > /tmp/download.log &

The following list describes the options in the preceding command:

  • --retry 10: enables up to 10 retries if the download fails.
  • -C -: enables resumable uploads.
  • -o: specifies the save path and name of the backup file that you want to download.
  • nohup: prevents interruptions to the download and specifies that the process automatically exits after the download is complete. If you accidentally replicate data or disconnect your database client during the download, the download is interrupted.

FAQ

How do I use the data backup files and log backup files that I downloaded?

You can restore the data of the backup files that you downloaded by using the standard download feature to self-managed MySQL instances. For more information, see Restore the data of an ApsaraDB RDS for MySQL instance from a physical backup file to a self-managed MySQL database or Restore the data of an ApsaraDB RDS for MySQL instance from a logical backup file to a self-managed MySQL instance.

My RDS instance runs standard SSDs or ESSDs. What do I do if the "ERROR 1148 (42000): The used command is not allowed with this MySQL version" error message appears when I restore the data of a backup file that I downloaded by using the advanced download feature to a self-managed MySQL instance?

Run the show variables like 'local_infile'; command on the self-managed MySQL instance. If the output is OFF, execute the SET statement to set the global local_infile parameter to 1 to enable file import. After the preceding operations are complete, run the import script again.

Related operations

Operation Description
DescribeBackups You can call the DescribeBackups operation to query the data backup files of an instance.
DescribeBinlogFiles You can call the DescribeBinlogFiles operation to query the binary log files of an instance.