This topic describes how to download the backup files of a PolarDB cluster.
Release date
November 24, 2023
This feature is in canary release and will be officially launched soon.
Scenarios
In addition to full data restoration and individual database or table restoration, PolarDB provides the backup download feature. You can download the backup files of a cluster to your computer for the following purposes:
Query the data in a backup file.
Query data at a specific point in time.
Save backup files to your computer.
Download backup files for auditing.
Upload backup files to an Object Storage Service (OSS) bucket.
The downloaded backup data cannot be directly restored to a PolarDB for MySQL cluster. However, you can restore the downloaded backup data to a self-managed MySQL database. For more information, see Restore the data of a PolarDB cluster to a self-managed MySQL database by using snapshot backup files.
Billing
You are charged for file conversion and Internet traffic generated for the download.
If you fail to download backup files, no fees are incurred.
Internet traffic fees
Downloads over an internal network: You are not charged for traffic that you consume.
Downloads over the Internet: After the free quota of 500 GB per cluster-month is exhausted, you are charged for excess traffic that you consume on a pay-as-you-go basis. Fees are deducted from your account on a daily basis. For more information, see Network traffic fees.
We recommend that you purchase a subscription network plan to offset the fee for Internet traffic that is used to download the backup files. The larger the capacity of the network plan, the greater the discount. For more information, see Use network plans.
File conversion fees
In PolarDB, backup files can be converted into CSV, SQL, or Parquet files. You are charged for file conversion. No free quota is provided for backup file conversion. The following table describes the unit prices for backup file conversion in different regions.
Region | Unit price (USD per GB) |
Public cloud-related regions | 0.03125 |
Log on to the PolarDB console. On the Download Backup tab of the Backup and Restoration page, you can view Monthly Backup Data Size (for file conversion data size) and Monthly Internet Traffic.
Prerequisites
Supported versions
The cluster is a PolarDB for MySQL Enterprise Edition cluster.
The cluster runs PolarDB for MySQL 5.6, 5.7, 8.0.1, or 8.0.2.
Supported regions
China (Chengdu), 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, US (Silicon Valley), US (Virginia), and Germany (Frankfurt).
The feature will be available in other regions soon.
Permission requirements for RAM accounts
The authentication capability of the backup download feature is based on the policy management feature of Resource Access Management (RAM).
Grant the permissions to download backup files
If you cannot use the backup download feature, such as for creating and querying download tasks, check whether the AliyunDBSFullAccess policy is attached to the RAM user that you use. The policy specifies the permissions to use Database Backup (DBS). For more information about how to grant permissions to a RAM user, see Grant permissions to a RAM user.
Revoke the permissions to obtain download URLs
If you want the RAM user to use the backup and restoration feature but do not want the RAM user to obtain download URLs, you can create a custom policy to revoke the permissions to obtain download URLs. For more information, see Create custom policies. Sample script:
{
"Version": "1",
"Statement": [
{
"Effect": "Deny",
"Action": "dbs:DescribeDownloadBackupSetStorageInfo",
"Resource": "*"
}
]
}
After you create the custom policy, you must attach the policy to the RAM user. For more information, see Grant permissions to a RAM user. This way, the RAM user cannot obtain download URLs.
Grant read-only RAM users the permissions to download backup files
To ensure security, a read-only RAM user cannot download backup files if the AliyunPolardbReadOnlyAccess policy is attached to the RAM user. The policy specifies read-only permissions on PolarDB resources.
If the RAM user needs to download backup files, you can attach the AliyunDBSReadOnlyAccess policy to the RAM user. This policy specifies read-only permissions on DBS resources. This way, the RAM user can view the download URL for a created download task.
For more information about how to grant permissions to a RAM user, see Grant permissions to a RAM user.
Other requirements
The disk encryption feature is disabled for your PolarDB cluster. The backup download feature is not supported in a PolarDB cluster for which the disk encryption feature is enabled.
Limits
The backup download feature allows you to export most schemas. However, some schemas cannot be exported.
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 backup download feature does not support fields of spatial data types. If your PolarDB cluster contains fields of the following spatial data types, backup file conversion fails:
GEOMETRY, POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, and GEOMETRYCOLLECTION
The CSV files that you export from your PolarDB cluster do not contain the following system databases:
information_schema
,mysql
,performance_schema
,sys
, and__recycle_bin__
If you set the Download Destination parameter to OSS, only Standard storage class is supported. For information about how to change storage classes, see Convert storage classes.
You can download only the data of level-1 backup files. You cannot download the data of level-2 backup files.
If cold data archiving is enabled for a cluster, you cannot download archived cold data. For more information, see Cold data archiving.
Procedure
Log on to the PolarDB console. Select a region in the upper-left corner and then click the ID of the cluster to go to the Basic Information page.
In the left-side navigation pane, click Backup and Restoration.
On the Backup and Restoration page, click Data Backups.
Find the backup set and click Download Cluster Backup in the Actions column.
NoteBy default, the PolarDB console displays the backup sets that are generated in the most recent eight days. If you want to view the backup sets that were generated more than eight days ago, you must change the default time range.
If Download Cluster Backup is not displayed, check whether the major engine version or region of the cluster meets the requirements that are described in Prerequisites.
In the Point in Time and Backup Set step of the wizard, select Download by Point in Time or Download by Backup Set and then click Next.
In the Instance, Database, and Table step of the wizard, click Next.
NoteBy default, Instance Download is selected.
In the Destination and Format step of the wizard, configure the download destination and format.
ImportantWe recommend that you set the Download Destination parameter to OSS to ensure efficiency.
The backup download task cannot be canceled after it is started.
OSS (recommended): PolarDB writes backup data directly to OSS. You must configure the bucket name and directory prefix of the OSS bucket.
NoteIf you do not have the permissions to access OSS resources, follow the instructions in the console to click
. After the permissions are granted, configure the parameters of the backup download task.URL: PolarDB provides an internal or external URL. You can use the URL to download backup data.
NoteIf you use the URL method to download backup data, the downloaded data is stored in the built-in storage of DBS. For more information, see Built-in storage and OSS.
URL downloads involve data packaging, which requires additional waiting time. The duration of this packaging process is largely dependent on the logical size of the backup set. If the logical size of the backup set is more than 1 TB, we recommend that you select OSS.
Configure the Download Format parameter.
NoteYou can set the Download Format parameter to CSV, SQL, Parquet, or CSV-with-header.
Read and select the instructions, and then click Complete.
The Backup Download tab appears.
ImportantWhen you download backup files, you are charged file conversion fees and Internet traffic fees. For more information, see Billing rules.
If you use a third-party download tool to download backup files, additional traffic may be generated and you may be charged additional fees. Proceed with caution. For more information, see Download commands.
Computing resources are competed to convert the downloaded backup sets. As a result, temporary resource allocation may fail, and the download task fails. The download task may also fail due to unsupported special data formats. If your download task fails, try again or contact DBS technical support.
No fees are generated for failed tasks.
If you set the Download Destination parameter to OSS and the status 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.
NoteIf you use this method, data is directly downloaded to your OSS bucket. You can use and delete the data based on your business requirements.
If you set the Download Destination parameter to URL and the status of the task changes to Finished, click Generate Link in the Download Destination column. In the Generate Link dialog box, configure the Validity Period parameter and click Generate Link. Then, you can download backup data by using the generated URL.
ImportantYou can obtain the URL within three days after the task finishes. The validity period of the URL is from 5 minutes to one day. The default validity period is 2 hours.
Finished tasks expire in three days. URLs become invalid after the tasks expire.
After the task expires, the corresponding data is automatically deleted after a period of time. If you want to use the data, you must initiate a new download task and obtain a new download URL.
We recommend that you save the URL at the earliest opportunity and keep the URL confidential.
You can use an SQL file, a CSV file or a CSV-with-header file that is downloaded and converted by using the backup download feature to restore the data of your PolarDB cluster to a self-managed MySQL database. For more information, see Restore the data of a PolarDB cluster to a self-managed MySQL database by using snapshot backup files.
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 to self-managed MySQL databases. For more information, see Restore the data of a PolarDB cluster to a self-managed MySQL database by using snapshot backup files.
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 backup download feature to a self-managed MySQL database?Execute the
SHOW VARIABLES LIKE 'local_infile';
statement on the self-managed MySQL database. If OFF is returned in the output, execute theSET
statement to set the global local_infile parameter to 1 to enable file import. After you perform the preceding operations, rerun the import script.Why is the backup file size displayed in the PolarDB console different from the size of the downloaded file?
The downloaded backup file is compressed. As a result, the size of the downloaded backup file is smaller than the file size that is displayed in the PolarDB console. You can check the data integrity after the data is restored from the backup file.
Can I directly restore a backup file that is downloaded from the PolarDB console to another PolarDB cluster?
You cannot directly restore a backup file to another PolarDB cluster. If you want to restore the backup file to another PolarDB cluster, perform the following operations: Restore the backup file to a self-managed MySQL database and then migrate data from the self-managed database to the required PolarDB cluster. For more information, see Restore the data of a PolarDB cluster to a self-managed MySQL database by using snapshot backup files and From a self-managed MySQL database.
Can I cancel an ongoing backup download task?
No, you cannot cancel a backup download task after it is started.
Download commands
This section describes the commands that are commonly used to download backup files.
If the download speed is slower than 64 KB per second, the download may be interrupted. We recommend that you ensure optimal network status when you download a backup file.
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 the ossfs plug-in and the corresponding parameter settings, see ossfs and Options supported by ossfs.
We recommend that you use the commands that are provided in this topic, such as wget and curl, 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 larger than the size of the backup file, and you may be charged for traffic that is consumed to download the excess amount of data over the Internet.
wget
Command: nohup wget -c -t 0 "The URL of the backup file to download" -O The destination path and file name > 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 section describes the options in the preceding command:
-t 0: enables an unlimited number of retries.
-c: enables resumable uploads.
-O: specifies the destination path and file name.
nohup: prevents the download from being interrupted when you accidentally replicate data or disconnect your database client during the download. If you specify this option, the download process automatically exits after the download is completed.
curl
Command: nohup curl -C - --retry 10 "The URL of the backup file to download" -o The user-defined name of the downloaded 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 section 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 destination path and file name.
nohup: prevents the download from being interrupted when you accidentally replicate data or disconnect your database client during the download. If you specify this option, the download process automatically exits after the download is completed.
Related API operations
API | Title | Description |
---|---|---|
DescribeDownloadBackupSetStorageInfo | DescribeDownloadBackupSetStorageInfo | Queries the storage information of a downloaded backup set. |
DescribeDownloadSupport | DescribeDownloadSupport | Queries whether an instance supports the advanced download feature. |
CreateDownload | CreateDownload | Creates an advanced download task for an ApsaraDB RDS for MySQL instance, an ApsaraDB RDS for PostgreSQL instance, or a PolarDB for MySQL cluster. |
DescribeDownloadTask | DescribeDownloadTask | Queries the advanced download tasks for an ApsaraDB RDS for MySQL instance, an ApsaraDB RDS for PostgreSQL instance, or a PolarDB for MySQL cluster. |