All Products
Search
Document Center

ApsaraDB RDS:Restore the data of an ApsaraDB RDS for MySQL instance to a self-managed MySQL database from a physical backup file

Last Updated:Mar 30, 2026

Use Percona XtraBackup to restore a full physical backup from an ApsaraDB RDS for MySQL instance to a self-managed MySQL database running on Linux.

Important

This procedure requires a Linux environment and applies only to RDS instances that use local disks (Premium Local SSDs). It restores all data in the backup — not individual databases or tables. If your setup does not match these requirements, see Limitations.

How it works

  1. Download a physical backup file from the ApsaraDB RDS console.

  2. Decompress the file using qpress and xbstream.

  3. Run Percona XtraBackup to restore the data to a new data directory on the self-managed MySQL host.

  4. Start the self-managed MySQL process using the restored data directory.

  5. Connect to the database and verify the data.

Limitations

Prerequisites

Before you begin, make sure that:

  • Your RDS instance runs MySQL 8.0, 5.7, 5.6, or 5.5 on RDS High-availability Edition with Premium Local SSDs. Check these details on the Basic Information page of the instance.

  • No tables in the instance are encrypted with TDE.

  • The RAM user you are using has permission to download backup files. For details, see Authorize a RAM user with read-only permissions to download backup files.

  • The self-managed MySQL database runs the same major version as your RDS instance (for example, both run MySQL 8.0).

  • The self-managed MySQL database runs on Linux. The examples in this topic use CentOS 7.9 64-bit.

Potential impacts

  • If other services are running in the self-managed MySQL database, they become unavailable while the restore is in progress.

  • The restore writes data to a new data directory and does not affect the existing data in the self-managed database.

Billing

  • Manual backups consume backup storage. Excess storage beyond the free quota is billed. See Billable items and pricing for backup storage.

  • Downloading over the Internet generates traffic charges if the traffic exceeds the free quota. To avoid these charges, download the backup file using an internal URL when the self-managed MySQL host and the RDS instance are in the same region and VPC. See Download charges.

Prepare the environment

1. Set up directories

Run the following commands on the Linux host where the self-managed MySQL database resides.

Create the backup decompression directory to hold the decompressed backup files:

sudo mkdir /var/mysql_bkdata
sudo chown -R $USER:$USER /var/mysql_bkdata

Create the data directory to which the backup data will be restored:

sudo mkdir /var/mysql_newdata
sudo chown -R $USER:$USER /var/mysql_newdata
$USER:$USER refers to the current user and user group, resolved automatically from the environment. No substitution is needed.

2. Locate the MySQL configuration file

The configuration file path varies by MySQL version:

MySQL version Configuration file path
8.0 / 5.7 /etc/my.cnf
5.6 /usr/my.cnf
5.5 Run echo "[mysqld]" | sudo tee /etc/my.cnf to create it

To find the path on your host:

sudo find / -name my.cnf
If the result differs from the table above, use the actual path when running subsequent commands.

3. Install tools

XtraBackup version by MySQL version:

RDS MySQL version XtraBackup to install
MySQL 8.0 RDS XtraBackup 8.0 (ApsaraDB custom build)
MySQL 5.7 / 5.6 / 5.5 Percona XtraBackup 2.4
Important

For MySQL 8.0, use the ApsaraDB-provided XtraBackup build. The open-source Percona XtraBackup may have compatibility issues with RDS redo log files.

Install XtraBackup for MySQL 8.0

Download the package for your host OS and upload it to the server (see Upload or download files for ECS instances). Then install it. The following table shows download links and example installation commands — the examples assume the package is downloaded to /XtraBackup8.0/.

Host environment Download Installation command
Linux 6 (x86_64) RDS XtraBackup 8.0.rpm) sudo yum localinstall -y /XtraBackup8.0/t-rds-xtrabackup-80-8.0.31-20230817110455.alios6.x86_64
Linux 7 (x86_64) RDS XtraBackup 8.0 sudo yum localinstall -y /XtraBackup8.0/t-rds-xtrabackup-80-8.0.31-20230817110455.alios7.x86_64.rpm
Linux 7 (ARM AArch64) RDS XtraBackup 8.0 sudo yum localinstall -y /XtraBackup8.0/t-rds-xtrabackup-80-8.0.31-20230817110455.alios7.aarch64.rpm
Linux 8 (ARM AArch64) RDS XtraBackup 8.0 sudo yum localinstall -y /XtraBackup8.0/t-rds-xtrabackup-80-8.0.31-20230817110455.al8.aarch64.rpm

After installation, the XtraBackup executable is at /u01/xtrabackup80/bin/xtrabackup. This directory is not added to PATH automatically. Either use the full path (as shown in this topic) or add the directory to PATH manually.

Install XtraBackup for MySQL 5.7, 5.6, or 5.5

Install Percona XtraBackup 2.4. Example using version 2.4.28:

wget https://downloads.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.28/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.28-1.el7.x86_64.rpm
sudo yum localinstall -y percona-xtrabackup-24-2.4.28-1.el7.x86_64.rpm

Install qpress

# Download the qpress executable
wget "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20230406/flxd/qpress-11-linux-x64.tar"

# Extract the archive
tar -xvf qpress-11-linux-x64.tar

# Grant execute permissions
sudo chmod 775 qpress

# Make qpress available system-wide
sudo cp qpress /usr/bin

Step 1: Download the backup file

  1. Log in to the ApsaraDB RDS console. In the top navigation bar, select the region where your RDS instance resides, then click the instance ID.

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

  3. Choose Base Backups > Data Backup. Find the physical backup file to download and click Download Instance Backup in the Actions column.

  4. In the Download Instance Backup Set dialog box, click Copy Internal URL or Copy Public URL.

    Important

    - Internal URL: The self-managed MySQL host and the RDS instance must be in the same VPC. Cross-region VPCs and classic network-to-VPC configurations are not supported. - Public URL: Internet traffic charges apply if you exceed the free quota. - A download URL is valid for 1 hour after it is generated. Refresh the page to get a new URL if it expires.

  5. On the Linux host, run the following command to download the backup file. Replace the URL with the one you copied.

    - Enclose the URL in single quotation marks so the shell treats it as a literal string. - Replace test_xb.qp with your preferred filename, but keep the same extension as in the download URL. - Physical backup file extensions: _xb.qp or _qp.xb for MySQL 8.0/5.7/5.6; tar.gz for MySQL 5.5. - Do not modify or delete a physical backup file. If you need to modify the data, restore it to the self-managed database first.
    wget -c 'https://****.bak.rds.aliyuncs.com/****_xb.qp?****' -O test_xb.qp

Step 2: Decompress the backup file

Run the decompression command that matches your backup file extension. Replace the filename and directory with your actual values.

Important

Make sure both qpress and Percona XtraBackup are installed before running these commands. See Prepare the environment.

`_xb.qp` files

# MySQL 8.0
qpress -do test_xb.qp | /u01/xtrabackup80/bin/xbstream -x -v -C /var/mysql_bkdata/

# MySQL 5.5 / 5.6 / 5.7
qpress -do test_xb.qp | xbstream -x -v -C /var/mysql_bkdata/

`_qp.xb` files

# Step 1: Parse the file
cat test_qp.xb | xbstream -x -v -C /var/mysql_bkdata/

# Step 2: Decompress
## MySQL 5.5 / 5.6 / 5.7
innobackupex --decompress --remove-original /var/mysql_bkdata/

## MySQL 8.0
/u01/xtrabackup80/bin/xtrabackup --decompress --remove-original --target-dir=/var/mysql_bkdata/

`.tar.gz` files

tar -izxvf test.tar.gz -C /var/mysql_bkdata/

`.xb.gz` files

# MySQL 8.0
gzip -d -c test.xb.gz | /u01/xtrabackup80/bin/xbstream -x -v -C /var/mysql_bkdata/

# MySQL 5.5 / 5.6 / 5.7
gzip -d -c test.xb.gz | xbstream -x -v -C /var/mysql_bkdata/

Troubleshooting decompression errors

Error: `sh: qpress: command not found`

Install qpress. See Prepare the environment.

Error: `innobackupex` not found (for _qp.xb files)

Install Percona XtraBackup. See Prepare the environment.

Error: `can't change to dir to xx (errorcode: no such file or directory)` (for _qp.xb files)

Check that the target directory path and the backup filename are correct.

Step 3: Restore data

Before restoring, stop the self-managed MySQL database. Check for running MySQL processes and terminate them:

ps -ef | grep '[m]ysql'
sudo kill -9 <PID>

Follow the steps for your MySQL version.

MySQL 8.0

3.1 Prepare the backup

/u01/xtrabackup80/bin/xtrabackup --defaults-file=/var/mysql_bkdata/backup-my.cnf \
  --prepare --target-dir=/var/mysql_bkdata/
Parameter Description
--defaults-file Path to backup-my.cnf in the backup decompression directory. This file is created automatically when the backup is decompressed.
--prepare Prepares the backup for restoration.
--target-dir The backup decompression directory (/var/mysql_bkdata/ in this example).

3.2 Update `datadir` in the configuration file

Open the configuration file:

sudo vim /etc/my.cnf

Set datadir to the new data directory:

datadir = /var/mysql_newdata

Save and exit (press Esc, then type :wq).

3.3 Set directory ownership

chown -R mysql:mysql /var/mysql_newdata

3.4 Copy data to the new data directory

sudo xtrabackup --defaults-file=/etc/my.cnf --copy-back --target-dir=/var/mysql_bkdata/
Parameter Description
--defaults-file Path to my.cnf. XtraBackup reads datadir from this file to determine the restore destination.
--copy-back Copies the backup data to the data directory.
--target-dir The backup decompression directory. XtraBackup copies data from here to the data directory.

MySQL 5.7

3.1 Prepare the backup

innobackupex --defaults-file=/var/mysql_bkdata/backup-my.cnf --apply-log /var/mysql_bkdata/
Parameter Description
--defaults-file Path to backup-my.cnf in the backup decompression directory.
--apply-log Prepares the backup. The path that follows is the backup decompression directory.

3.2 Update `datadir` and InnoDB settings in the configuration file

Open the configuration file:

sudo vim /etc/my.cnf

Set datadir and add the InnoDB undo tablespace settings:

datadir = /var/mysql_newdata
innodb_undo_tablespaces=2
innodb_undo_directory=/var/mysql_newdata
Important

The value of innodb_undo_tablespaces must match the value in /var/mysql_bkdata/backup-my.cnf. Check the value with:

cat /var/mysql_bkdata/backup-my.cnf | grep innodb_undo_tablespaces

Save and exit.

3.3 Copy data to the new data directory

sudo innobackupex --defaults-file=/etc/my.cnf --copy-back /var/mysql_bkdata/
Parameter Description
--defaults-file Path to my.cnf. XtraBackup reads datadir from this file.
--copy-back Copies backup data to the data directory specified by datadir.

MySQL 5.6

3.1 Prepare the backup

innobackupex --defaults-file=/var/mysql_bkdata/backup-my.cnf --apply-log /var/mysql_bkdata/

3.2 Update `datadir` in the configuration file

Open the configuration file:

sudo vim /usr/my.cnf

Add the datadir setting:

datadir = /var/mysql_newdata

Save and exit.

3.3 Copy data to the new data directory

sudo innobackupex --defaults-file=/usr/my.cnf --copy-back /var/mysql_bkdata/

MySQL 5.5

3.1 Prepare the backup

innobackupex --defaults-file=/var/mysql_bkdata/backup-my.cnf --apply-log /var/mysql_bkdata/

3.2 Update `datadir` and InnoDB log settings in the configuration file

Open the configuration file:

sudo vim /etc/my.cnf

Add the datadir and InnoDB log file size settings:

datadir = /var/mysql_newdata
innodb_log_file_size=1048576000
Important

The value of innodb_log_file_size must match the value in /var/mysql_bkdata/backup-my.cnf. Check the value with:

cat /var/mysql_bkdata/backup-my.cnf | grep innodb_log_file_size

Save and exit.

3.3 Copy data to the new data directory

sudo innobackupex --defaults-file=/etc/my.cnf --copy-back /var/mysql_bkdata/

Troubleshooting restoration errors

Error: `xtrabackup: Unknown error 3613`

Update Percona XtraBackup to the latest version and retry.

Error: `Original data directory /var/mysql_newdata is not empty!`

Clear the directory and retry:

sudo rm -rf /var/mysql_newdata/*

Error: `InnoDB: Encryption information in datafile: ./xxx.ibd can't be decrypted`

Check whether TDE is enabled. If encrypted tables exist, decrypt them and redo the restore from the beginning. See Configure TDE.

If TDE is disabled, verify that the correct XtraBackup version is installed for your MySQL version.

Error: `innobackupex: File 'undo001' not found (Errcode: 2 - No Such file or directory)`

The undo file format differs by database version. Confirm that the self-managed MySQL version matches the RDS instance version.

Step 4: Start the database

MySQL 8.0 or 5.7

  1. (Optional) If the lower_case_table_names parameter on your RDS instance is set to 1, add the same setting to my.cnf. To check the parameter value, see View the parameters of an ApsaraDB RDS for MySQL instance. Open the file:

    sudo vim /etc/my.cnf

    Add:

    lower_case_table_names=1

    Save and exit.

  2. Grant ownership of the data directory to the mysql user:

    sudo chown -R mysql:mysql /var/mysql_newdata
  3. Start the MySQL process:

    Parameter Description
    --defaults-file Path to the MySQL configuration file (/etc/my.cnf in this example).
    --user The user running the database process. Always mysql.
    --datadir The data directory to use on startup (/var/mysql_newdata in this example).
    sudo mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/var/mysql_newdata &

MySQL 5.6

  1. (Optional) If lower_case_table_names is 1 on the RDS instance, add it to /usr/my.cnf:

    sudo vim /usr/my.cnf

    Add:

    lower_case_table_names=1

    Save and exit.

  2. Grant ownership of the data directory:

    sudo chown -R mysql:mysql /var/mysql_newdata
  3. Start the MySQL process:

    sudo mysqld --defaults-file=/usr/my.cnf --user=mysql --datadir=/var/mysql_newdata &

MySQL 5.5

  1. Grant ownership of the data directory:

    sudo chown -R mysql:mysql /var/mysql_newdata
  2. Start the MySQL process:

    sudo mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/var/mysql_newdata &

Troubleshooting startup errors

Error: `mysqld: [ERROR] Failed to open required defaults file: /etc/my.cnf` (Ubuntu)

AppArmor on Ubuntu blocks access to the configuration file. Run:

apt install -y apparmor-utils
aa-complain /usr/sbin/mysqld

Error: `error 1105 Unknown error` after startup, or the database fails to start

Change the storage engine for system tables:

USE mysql;
ALTER TABLE proc ENGINE=myisam;
ALTER TABLE event ENGINE=myisam;
ALTER TABLE func ENGINE=myisam;

If ERROR 1067 (42000): Invalid default value for 'modified' appears, run this first:

SET SQL_MODE='ALLOW_INVALID_DATES';

Error: `InnoDB: Assertion failure in thread 140xxx in file page0zip.icne xxx`

This typically indicates insufficient disk space. Expand the disk and retry.

Errors: `[ERROR] Failed to open the relay log`, `[ERROR] Slave: Failed to initialize the master info`, `[ERROR] Failed to create or recover replication info repositories`

These messages appear because the RDS instance uses HA mode but the self-managed database has no primary/secondary nodes. The database starts normally — ignore these errors.

Error: `[ERROR] Data Dictionary initialization failed`

The RDS underlying OS is Linux. Perform the restore on a Linux host to avoid OS compatibility issues.

Cannot start with `sudo systemctl start mysqld`

SELinux may be running in enforcing mode. Check with:

getenforce
  • In development or test environments, change the SELinux mode to permissive and then run sudo systemctl start mysqld.

  • In production environments, check SELinux audit logs to identify the blocked operation and update the SELinux policy accordingly.

Step 5: Verify the restoration

  1. Connect to the self-managed MySQL database:

    If you have forgotten the credentials, add --skip-grant-tables to the startup command (step 4) to bypass the permission check. Reset the credentials after logging in.
    mysql -u<username> -p<password>
  2. Verify that the expected databases are present:

    SHOW DATABASES;

    If you can see only system databases or a subset of databases, restart the self-managed database and reconnect using the root account or the privileged account from the original RDS instance.

  3. If data timestamps are in the wrong time zone, set time_zone on the self-managed database to match the RDS instance. If the RDS time_zone parameter is set to system, look up the region of the RDS instance and use the corresponding time zone.

Troubleshooting connection errors:

Error: `Access denied for user 'XXX'`

Check whether the username and password of the account used to connect to the database are correct. The account must have been created on the RDS instance.

Password after restore:

FAQ

Can I restore data from a downloaded backup file to another RDS instance?

No. Downloaded backup files cannot be directly loaded into another RDS instance. Two alternatives:

How do I restore data to a specific point in time?

Download the log backup files for the target time range from the console, then use them for point-in-time recovery. See Download backup files and Restore data to a specific point in time.

How do I restore or migrate data from an RDS Basic Edition instance?

RDS Basic Edition supports only snapshot backups and does not support physical backup downloads. Use one of these methods:

Can I restore data from multiple RDS instances into one self-managed MySQL database?

No. Each physical backup restore targets a separate self-managed MySQL database. After restoring each instance to its own database, use DTS or mysqldump to consolidate the data. See Migrate data from a self-managed MySQL database to ApsaraDB RDS for MySQL.

How do I restore the data of my RDS for MySQL instance to a self-managed MySQL database?

After I restore a physical backup to a self-managed database, does the privileged account retain its original permissions?

Yes. The privileged account still has original permissions. Account permissions are not affected by backups.

What's next