Skip to content

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

4 minute read
0

I want to use Amazon Simple Storage Service (Amazon S3) to migrate data from my self-managed MySQL database to an Amazon Aurora MySQL-Compatible Edition DB cluster.

Resolution

Install Percona Xtrabackup

To directly copy your MySQL data directory and files, use the Percona XtraBackup tool. It's a best practice to use this tool for large databases for a faster restoration time. For more information about the tool, see Percona XtraBackup - Documentation on the Percona XtraBackup website.

Note: You can't use the Restore from S3 option to restore snapshots that you exported to Amazon S3.

For instructions on how to migrate MySQL 5.7, see Installing Percona XtraBackup 2.4 on the Percona XtraBackup website. For instructions on how to migrate MySQL 8.0, see Install Percona XtraBackup 8.0 overview on the Percona XtraBackup website. Make sure that the Percona XtraBackup version is compatible with the engine version of your source database.

Back up your data

Complete the following steps:

  1. Connect to your Amazon Elastic Compute Cloud (Amazon EC2) instance or on-premises server that runs the MySQL database.
  2. To back up the database, run the following command:
    xtrabackup --backup --user=myuser --password --stream=xbstream \--target-dir=/on-premises/s3-restore/backup | split -d --bytes=500MB \- /on-premises/s3-restore/backup/backup.xbstream

Note: Replace myuser with your source database username and /on-premises/s3-restore/backup with the directory where you want to create the output file. This command creates a backup of your MySQL database that's split into multiple xbstream files.

Aurora doesn't restore everything from your source. You must manually recreate the following resources:

  • User AWS accounts
  • Functions
  • Stored procedures
  • Time zone information

For more information on Percona XtraBackup, see Backup considerations.

Upload your backup to an S3 bucket

Complete the following steps:

  1. Create an S3 bucket.
    Note: Your bucket must be in the same AWS Region as your EC2 instance and your Aurora DB cluster.
  2. Select your new bucket, and then choose Create folder.
  3. Select the new folder, and then choose Upload.
  4. Upload the files that the Percona XtraBackup tool created.
  5. (Optional) Configure additional properties such as permissions or properties based on your use case.
  6. Choose Upload.
    Note: When you upload a file to an S3 bucket, you can use server-side encryption to encrypt the data.

Import your database from Amazon S3 to Aurora

Complete the following steps:

  1. Sign in to the AWS Management Console, and then open the Aurora and RDS console.
  2. In the navigation pane, choose Dashboard.
  3. Under Create a database, choose Restore from S3.
  4. Under S3 Source, from the S3 bucket dropdown list, select the S3 bucket that you created.
  5. (Optional) For S3 prefix, enter a file path prefix for the files stored in your Amazon S3 bucket.
    Important: Don't use leading or trailing slashes (/) when you enter the bucket name.
  6. For Engine version, enter your source Aurora MySQL engine version. You can also enter a later engine version.
  7. For IAM role, you can choose an existing IAM role.
  8. (Optional) You can also create a new IAM role by choosing Create a new role.
  9. Choose your Cluster storage configuration.
  10. Choose your Instance configuration.
  11. Configure your Settings.
  12. For Availability & durability, choose whether to create a Multi-AZ deployment.
  13. For Connectivity, review your connectivity settings.
  14. Choose Create database.
  15. After the cluster is in the Available state, verify that your Aurora MySQL DB cluster is found under Databases.

Related information

Physical migration from MySQL by using Percona XtraBackup and Amazon S3

Percona XtraBackup

The backup cycle - full backups on the Percona XtraBackup website

AWS OFFICIALUpdated 7 months ago