How do I migrate MySQL data to an Amazon Aurora cluster using Amazon S3?

Last updated: 2019-04-23

I want to migrate data from MySQL to Amazon Aurora. How do I restore MySQL data to an Amazon Aurora cluster using Amazon Simple Storage Service (Amazon S3)?


Amazon Aurora is compatible with MySQL 5.5 to MySQL 5.6. To restore a MySQL innobackupex backup, first install Percona Xtrabackup (version 2.3 or later) to your Amazon Elastic Compute Cloud (Amazon EC2) instance by using a command similar to the following: 

sudo yum install percona-xtrabackup-file_name_and_extension

Note: Replace file_name_and_extension with the appropriate file name and extension based on your Percona Xtrabackup package, similar to the following:

sudo yum install percona-xtrabackup-24-2.4.7-1.el7.x86_64.rpm

After configuring the environment, you can upload your backup to Amazon Simple Storage Service (Amazon S3) and then create an Aurora cluster.

Launch an EC2 instance and back up your MySQL database

1.    Launch an EC2 instance.

2.    After the instance is running, connect to the instance by using SSH.

3.    Start the MySQL service and note the MySQL version.

4.    Enable EPEL.

5.    Make a directory for the backup using the following commands:

mkdir backup
cd backup

Using a command similar to the following, back up the instance:

sudo innobackupex -u root -ppassword --stream=tar /tmp | gzip -9 > ./mybackup.tar.gz

Upload your backup to an S3 bucket

1.    Create an S3 bucket.
Note: Your bucket must be in the same Region as your EC2 instance and your new Amazon Aurora cluster.

2.    Choose the bucket that you created, and then choose Create Folder.

3.    Choose the folder, and then choose Upload.

4.    Upload the files, and then set the permissions.

5.    Set the properties, and then choose Upload.

Import your database from Amazon S3 to Aurora

1.    Open the Amazon Relational Database Service (Amazon RDS) console, and then choose Dashboard in the navigation pane.

2.    Choose Restore Aurora DB Cluster from S3.

3.    Enter the Source Engine Version that you noted earlier.

4.    From the S3 Backup Location drop-down menu, select the S3 bucket that you created. Enter your S3 Bucket Prefix.
Note: Don't use leading or trailing slashes ("/") when entering the bucket name in the S3 Bucket Prefix field.

5.    Create an IAM role to give Amazon RDS permission to access the S3 bucket, and then choose Next Step.

6.    Specify your DB details and choose Next Step.

7.    Configure your Advanced Settings and Database Options. Enter the IAM role that you created for the DB Cluster Identifier.

8.    Choose Launch DB Instance.

9.    After the cluster is available, choose View Your DB Instances to confirm that the Aurora instance was created successfully.