All Products
Search
Document Center

ApsaraDB RDS:Migrate the data of a self-managed instance that runs MySQL 5.7 or MySQL 8.0 to an ApsaraDB RDS for MySQL instance

Last Updated:Aug 26, 2026

Use this method when your self-managed MySQL instance can be taken offline during migration. You take a full physical backup with Percona XtraBackup, stream it to Object Storage Service (OSS), and import it through the ApsaraDB RDS console to create a new RDS instance.

If your database cannot be taken offline, use Data Transmission Service (DTS) to migrate with minimal downtime.

Prerequisites

Before you begin, make sure you have:

  • A self-managed MySQL instance that meets the migration requirements. See Limitations for the full list.

  • An OSS bucket in the same region as your destination RDS instance. See Create buckets if you need to create one.

  • Go and Unzip installed on the host running the self-managed MySQL instance.

Limitations

Review these constraints before proceeding:

Category

Constraint

MySQL version

Source must run MySQL 5.7.32 or earlier, or MySQL 8.0.18 or earlier. Source and destination must run the same MySQL version.

Backup tool

MySQL 5.7 requires Percona XtraBackup 2.4. MySQL 8.0 requires Percona XtraBackup 8.0.

Backup scope

Full backup only. Differential and log backup files are not supported. Incremental data generated after the backup completes is not included.

XtraBackup options

The --tables, --tables-exclude, --tables-file, --databases, and --databases-file options are not supported.

Backup file format

The file must be in _QP.XB format, or compressed into TAR.GZ. The file name cannot contain special characters.

OSS encryption

Set Encryption Method to None when creating the OSS bucket. Encrypted buckets are not supported.

OSS region

The OSS bucket must be in the same region as the RDS instance.

OSS file size

Maximum 16 TB when uploading in parts via CLI.

Data directory

The datadir directory must be the default storage path. Run mysqladmin -u<username> -p<password> variables | grep datadir to verify.

InnoDB configuration

innodb_data_file_path must be set to the default value ibdata1.

Destination

Data can only be restored to a new RDS instance — not to an existing one. The destination must be a pay-as-you-go instance running MySQL 5.7 or MySQL 8.0 on RDS Basic Edition with standard SSDs.

Storage

The destination RDS instance must have more storage than the source data.

Not migrated

User accounts, custom functions, stored procedures, and time zone information are not migrated. Record these before migration and add them manually after.

GTID replication

If you plan to replicate incremental data after migration, enable GTID-based replication and set gtid_mode and enforce_gtid_consistency to ON in the source instance.

AliyunRDSImportRole

After you authorize ApsaraDB RDS to access OSS, a RAM role named AliyunRDSImportRole is created in Resource Access Management (RAM). Do not modify or delete this role.

Backup retention

Do not delete the backup file from OSS before the migration is complete.

Identify objects that are not migrated

Run the following query on your source instance to list stored procedures and functions that you need to re-create after migration:

SELECT ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE
FROM information_schema.routines
WHERE ROUTINE_SCHEMA NOT IN ('sys', 'information_schema', 'performance_schema', 'mysql');

Also record user accounts and time zone settings before proceeding.

How it works

  1. Install Percona XtraBackup on the host running the self-managed MySQL instance.

  2. Install MySQL Backup Helper, which provides backup_helper (compatibility check) and oss_stream (upload to OSS).

  3. Run a compatibility check, take a full backup, and stream it directly to OSS. Then import the backup file through the ApsaraDB RDS console to create a new RDS instance.

The environment in this guide uses an Elastic Compute Service (ECS) instance running CentOS Linux V8.3.2011. For Ubuntu-specific steps, see Appendix 1: Install Percona XtraBackup on Ubuntu and Appendix 2: Install Go and Unzip on Ubuntu.

Step 1: Install Percona XtraBackup

Percona XtraBackup is a hot backup tool for MySQL that supports full backups without impacting uptime. Install the version that matches your MySQL version.

MySQL 5.7

MySQL 5.7 — uses Percona XtraBackup 2.4:

wget https://downloads.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.29/binary/redhat/8/x86_64/percona-xtrabackup-24-2.4.29-1.el8.x86_64.rpm
yum localinstall percona-xtrabackup-24-2.4.29-1.el8.x86_64.rpm

MySQL 8.0

MySQL 8.0 — uses Percona XtraBackup 8.0:

wget https://downloads.percona.com/downloads/Percona-XtraBackup-8.0/Percona-XtraBackup-8.0.35-31/binary/redhat/8/x86_64/percona-xtrabackup-80-8.0.35-31.1.el8.x86_64.rpm
yum localinstall percona-xtrabackup-80-8.0.35-31.1.el8.x86_64.rpm

For Ubuntu, see Appendix 1.

Step 2: Install MySQL Backup Helper

MySQL Backup Helper provides two tools: backup_helper checks whether your instance supports migration, and oss_stream streams the backup directly to OSS.

Install dependencies (CentOS)

sudo yum install -y go
sudo yum install -y unzip

For Ubuntu, see Appendix 2.

Build MySQL Backup Helper

  1. Download the source code:

    wget https://github.com/aliyun/mysql-backup-helper/archive/refs/heads/master.zip
  2. Decompress the package:

    unzip master.zip
  3. Build backup_helper:

    cd mysql-backup-helper-master
    go build -a -o backup_helper main.go
  4. Build oss_stream:

    cd oss_stream
    go build -a -o oss_stream oss_stream.go

Step 3: Back up and migrate

3.1 Check migration compatibility

Run backup_helper to verify that the source instance supports migration:

cd ~/mysql-backup-helper-master && ./backup_helper \
  -host <host-ip> \
  -port <port> \
  -user <username> \
  --password <password>

Replace the placeholders with your actual values:

Placeholder

Description

Example

<host-ip>

IP address of the host running the MySQL instance

127.0.0.1

<port>

MySQL port

3306

<username>

Root account username

root

<password>

Root account password

Aa123456@

If the check passes, proceed to the next step.

3.2 Back up and upload to OSS

Warning

Percona XtraBackup writes the full command line (including passwords) to the xtrabackup_info file inside the backup. After the upload completes, check that this file does not expose sensitive credentials.

Run the backup and stream it directly to your OSS bucket. Select the command for your MySQL version.

MySQL 5.7

MySQL 5.7 — uses innobackupex:

innobackupex --backup \
  --host=<host-ip> \
  --port=<port> \
  --user=<username> \
  --password=<password> \
  --stream=xbstream \
  --compress <temp-dir> | \
  ./mysql-backup-helper-master/oss_stream/oss_stream \
  -accessKeyId <AccessKey-ID> \
  -accessKeySecret <AccessKey-secret> \
  -bucketName <bucket-name> \
  -endpoint <OSS-endpoint> \
  -objectName <backup-file-name>

Example:

innobackupex --backup --host=127.0.0.1 --port=3306 --user=root --password=Aa123456@ \
  --stream=xbstream --compress /root/mysql/data | \
  ./mysql-backup-helper-master/oss_stream/oss_stream \
  -accessKeyId LTAI**************** \
  -accessKeySecret ****** \
  -bucketName test \
  -endpoint oss-ap-southeast-1.aliyuncs.com \
  -objectName backup_qp.xb

MySQL 8.0

MySQL 8.0 — uses xtrabackup:

xtrabackup --backup \
  --host=<host-ip> \
  --port=<port> \
  --user=<username> \
  --password=<password> \
  --stream=xbstream \
  --compress <temp-dir> | \
  ./mysql-backup-helper-master/oss_stream/oss_stream \
  -accessKeyId <AccessKey-ID> \
  -accessKeySecret <AccessKey-secret> \
  -bucketName <bucket-name> \
  -endpoint <OSS-endpoint> \
  -objectName <backup-file-name>

Example:

xtrabackup --backup --host=127.0.0.1 --port=3306 --user=root --password=Aa123456@ \
  --stream=xbstream --compress /root/mysql/data | \
  ./mysql-backup-helper-master/oss_stream/oss_stream \
  -accessKeyId LTAI**************** \
  -accessKeySecret ******** \
  -bucketName test \
  -endpoint oss-ap-southeast-1.aliyuncs.com \
  -objectName backup_qp.xb

Replace the placeholders with your actual values:

Placeholder

Description

Example

<host-ip>

IP address of the host running the MySQL instance

127.0.0.1

<port>

MySQL port

3306

<username>

Root account username

root

<password>

Root account password

Aa123456@

<temp-dir>

Temporary directory for the backup

/root/mysql/data

<AccessKey-ID>

Your Alibaba Cloud AccessKey ID

LTAI5tXxx

<AccessKey-secret>

Your Alibaba Cloud AccessKey secret

xXxXxXx

<bucket-name>

Name of your OSS bucket

test

<OSS-endpoint>

Endpoint of your OSS bucket

oss-ap-southeast-1.aliyuncs.com

<backup-file-name>

Name to assign the backup object in OSS

backup_qp.xb

For large databases, run the command with nohup to prevent interruptions if the session disconnects. MySQL 5.7: MySQL 8.0:
nohup sh -c 'innobackupex --backup --host=127.0.0.1 --port=3306 --user=root --password=Aa123456@ --stream=xbstream --compress /root/mysql/data | ./mysql-backup-helper-master/oss_stream/oss_stream -accessKeyId LTAI**************** -accessKeySecret ****** -bucketName test -endpoint oss-ap-southeast-1.aliyuncs.com -objectName backup_qp.xb' &
nohup sh -c 'xtrabackup --backup --host=127.0.0.1 --port=3306 --user=root --password=Aa123456@ \
  --stream=xbstream --compress /root/mysql/data | \
  ./mysql-backup-helper-master/oss_stream/oss_stream \
  -accessKeyId LTAI**************** -accessKeySecret ****** \
  -bucketName test -endpoint oss-ap-southeast-1.aliyuncs.com -objectName backup_qp.xb' &

When the backup is complete, the terminal displays completed OK !.

Log in to the OSS console to confirm the file was uploaded successfully. If the upload failed, run the backup command again.

If OSS is temporarily unavailable, save the backup to a local file first and upload later. See Appendix 3: Back up locally and upload to OSS.

3.3 Import the backup in the ApsaraDB RDS console

  1. Log in to the ApsaraDB RDS console. In the top navigation bar, select the region of your destination RDS instance. In the left-side navigation pane, click Backups.

  2. On the User Backups tab, click Import Backup.

  3. In the Import Guide wizard, read the instructions and click Next until you reach 3. Import Data.

    Steps 1. Back Up Source Database and 2. Upload Backup Files to OSS in the wizard correspond to Steps 3.1 and 3.2 in this guide.
  4. In the 3. Import Data step, configure the following parameters and click OK.

    If ApsaraDB RDS is not authorized to access OSS, click Authorize at the bottom of this step. On the page that appears, click Confirm Authorization Policy.

    Parameter

    Description

    MySQL version

    Displays 5.7/8.0 automatically. Both MySQL 5.7 and MySQL 8.0 are supported.

    Region

    The region of the OSS bucket that stores the backup file. Must match the region of the destination RDS instance.

    OSS Bucket

    The OSS bucket that contains the backup file. See Upload objects for details.

    OSS file name

    The backup object in the OSS bucket. Supports fuzzy and exact match. The file must be in _QP.XB format, or compressed as TAR.GZ.

    Note

    An optional description to help identify the backup file.

    Zone

    The zone of the OSS bucket. Selecting a zone lets ApsaraDB RDS create a snapshot in seconds, reducing import time. The new RDS instance is created in this zone.

    Storage Capacity

    Storage required for the backup file. Valid values: 20–6000 GB. Defaults to 3× the backup file size (minimum 20 GB).

  5. On the User Backups tab, wait for the Status of the verification task to change from Verifying to Completed.

    Important

    Verification time varies. Instances with high write activity or large transactions during backup may take longer to verify.

  6. Find the backup file and click Restore in the Actions column.

  7. Configure the following parameters and click Next: Instance Configuration.

    Parameter

    Description

    Zone of Primary Node

    The zone for the primary RDS instance. Displayed only if you did not select a zone when importing the backup file.

    Storage Type

    ESSD PL1: A performance level 1 Enterprise SSD. Standard SSD: A standard elastic block storage device. See Storage types for details.

    Instance Type

    General-purpose (Entry-level): Exclusively allocated memory and I/O, with shared CPU and storage. See Primary ApsaraDB RDS instance types for the full list.

    Storage Capacity

    Storage provisioned for data files, system files, log files, and transaction files. Adjustable in 5 GB increments.

  8. Configure the following parameters and click Next: Confirm Order.

    Parameter

    Description

    Network Type

    Select VPC. A virtual private cloud (VPC) provides higher security and better performance. You must also configure VPC and vSwitch of Primary Node. The RDS instance and any ECS instance you want to connect must be in the same VPC.

    Parameter Template

    A system or custom parameter template. See Use a parameter template.

    Time Zone

    Time zone for the RDS instance.

    Table Name Case Sensitivity

    If table names in the source instance are case-sensitive, select Case-sensitive to maintain consistency.

  9. Confirm the instance configuration in the Parameters section, set Purchase Plan, accept the Terms of Service, and click Pay Now.

    ApsaraDB RDS takes 1–5 minutes to create the instance.

What's next

Configure the backup retention period

By default, the imported backup file is retained for 3 days. Adjust the retention period based on your requirements.

  1. Log in to the ApsaraDB RDS console. Select a region, then click Backups in the left-side navigation pane.

  2. Find the backup file. In the Expiration Time column, click Set Retention Period.

  3. Select a retention period from the drop-down list, or select Custom Retention Period and enter a value.

  4. Click OK.

If the expiration time exceeds 2099, it is displayed as Permanent.

Add tags to the backup file

  1. Log in to the ApsaraDB RDS console. Select a region, then click Backups.

  2. Find the backup file. In the Tags column, click +Add.

  3. In the dialog box, click Create a label, fill in Key and Value, click OK next to the fields to create the tag, then click OK in the lower-right corner.

    To use an existing tag, select it from the Select the label drop-down list.
  4. To update a tag, hover over it and click edit. In the tooltip, repeat step 3.

Check log data for incremental recovery

If data changes occurred in the source instance during the backup, the backup file contains log information for incremental recovery.

  1. Log in to the ApsaraDB RDS console. Select a region, then click Backups.

  2. Find the backup file and click View Details in the Actions column.

  3. In the message that appears, review the log data:

    • Master_Log_File: The first log file containing incremental data.

    • Master_Log_Position: The first log entry in that file containing incremental data.

The default retention period for backup validation records is 7 days. After migration, replicate incremental data from the source instance to the destination RDS instance as soon as possible.

Delete the backup file

If you no longer need the backup file, delete it to reduce storage costs.

  1. Log in to the ApsaraDB RDS console. Select a region, then click Backups.

  2. Find the backup file and click Delete in the Actions column.

  3. In the confirmation dialog box, click OK.

Upgrade your RDS instance

After migration, you can perform the following operations on the new RDS instance:

More operations on the User Backups tab

  • Filter columns: Click the Customize list items icon in the upper-right corner to show or hide columns. Move columns between the hidden list (left) and the displayed list (right) using the Right and Left icons. Click OK.

  • Export instance list: Click the Export the resource list icon to export backup information as a CSV file.

  • Refresh: Click the Refresh icon to refresh the User Backups tab.

Appendix 1: Install Percona XtraBackup on Ubuntu

Select the version that matches your MySQL version.

MySQL 8.0

  1. Install Percona XtraBackup:

    wget https://downloads.percona.com/downloads/Percona-XtraBackup-8.0/Percona-XtraBackup-8.0.35-31/binary/redhat/8/x86_64/percona-xtrabackup-80-8.0.35-31.1.el8.x86_64.rpm
    yum localinstall percona-xtrabackup-80-8.0.35-31.1.el8.x86_64.rpm
  2. Install qpress:

    sudo apt-get install -y qpress
If you see The following packages have unmet dependencies, run apt-get -f install to resolve dependencies, then retry.

Appendix 2: Install Go and Unzip on Ubuntu

Install the Go programming language:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install -y golang-go

Install Unzip:

sudo apt-get -y install unzip

Appendix 3: Back up locally and upload to OSS

Use this approach if OSS is temporarily unavailable when you run the backup.

Step 1: Back up to a local file

Select the command for your MySQL version.

MySQL 5.7:

innobackupex --backup \
  --host=<host-ip> --port=<port> \
  --user=<username> --password=<password> \
  --stream=xbstream --compress <temp-dir> \
  > /<backup-dir>/<backup-file-name>_qp.xb

Example:

innobackupex --backup --host=127.0.0.1 --port=3306 --user=root --password=Aa123456@ \
  --stream=xbstream --compress /root/mysql/data > /root/backup_qp.xb

MySQL 8.0:

xtrabackup --backup \
  --host=<host-ip> --port=<port> \
  --user=<username> --password=<password> \
  --stream=xbstream --compress <temp-dir> \
  > /<backup-dir>/<backup-file-name>_qp.xb

Example:

xtrabackup --backup --host=127.0.0.1 --port=3306 --user=root --password=Aa123456@ \
  --stream=xbstream --compress /root/mysql/data > /root/backup_qp.xb

Step 2: Upload the local file to OSS

When OSS is available, upload using oss_stream:

cat /<backup-dir>/<backup-file-name>_qp.xb | \
  ./mysql-backup-helper-master/oss_stream/oss_stream \
  -accessKeyId LTAI**************** \
  -accessKeySecret ******** \
  -bucketName test \
  -endpoint oss-ap-southeast-1.aliyuncs.com \
  -objectName backup_qp.xb

Example:

cat /root/backup_qp.xb | \
  ./mysql-backup-helper-master/oss_stream/oss_stream \
  -accessKeyId ******** \
  -accessKeySecret LTAI**************** \
  -bucketName test \
  -endpoint oss-ap-southeast-1.aliyuncs.com \
  -objectName backup_qp.xb