Migrate MySQL data to RDS/Aurora Using Xtrabackup

Mydbops
Dec 7, 2018
8
Mins to Read
All

Migrating large MySQL databases to the cloud can be slow with traditional methods. This guide explores Percona Xtrabackup, a tool for efficient backups and restores to Amazon RDS/Aurora, minimizing downtime.

Both RDS and Aurora is a DBAAS provided by Amazon. To know more on DBAAS you can view our presentation here.

When you are having a database in size of few GB, it would be very convenient to take a logical backup using a logical backup tool such as Mysqldump or Mydumper and restore it Amazon RDS/Aurora easily. But this is not the case when you are having a data size of a few hundred GB or TB, Where the logical backup and restore is very painful and time-consuming. To overcome this we can use Xtrabackup ( open source hot backup ), along with S3 to get the required instance in RDS/Aurora

Migrating MySQL to RDS/Aurora with Xtrabackup
Migrating MySQL to RDS/Aurora with Xtrabackup

AWS started supporting Xtrabackup restore for Aurora MySQL long time ago and is Supporting RDS from the last few months back, Both follow the same procedure, hence am using RDS for the purpose of restore, since Aurora is on costlier side.

Production Use Case:

Recently I had come across a situation of restoring xtrabackup to Aurora of data size 300GB and it worked like a charm and the data was absolutely fine and also data was restored in 2 hours.

Before going into the demo, first, let us see the limitations in this method

Limitations:

  • Only 5.6 is supported source and destination should be in 5.6
  • Only support for the whole instance (partial backups at database and table is not supported)
  • With RDS the size is limited to 6TB
  • Database objects and user accounts are not migrated properly (will see the workaround here)

The below command to stream the backup directly to S3 bucket, if you are low on local backup space streaming directly avoids the usage of local storage, also make sure to have a strong network pipe.

 
# xtrabackup --user=root --password='S3cret!123' --backup --stream=tar | gzip -c | s3cmd put - s3://kabileshs3/xtrabackup56.tar.gz
	

RDS/Aurora also supports the creation of instance from a tar compressed format and also the S3 footprint can be reduced by compressing the backup, Ensure the compressed backup size should not exceed 5TB, this is the max object size supported by S3.

Backup is now uploaded to s3

Creating RDS instance:

Go to RDS console as below

Migrating MySQL to RDS/Aurora with Xtrabackup

Click “Restore a database instance from Amazon S3”

Select engine to be used with the restored instance, Am using MySQL, You can select Aurora based on your use-case.

Migrating MySQL to RDS/Aurora with Xtrabackup

Next Specify source backup details ie, S3 and its details

Migrating MySQL to RDS/Aurora with Xtrabackup

Create a new IAM role for RDS to access the s3 bucket to make the access and restore of the backup

Migrating MySQL to RDS/Aurora with Xtrabackup

Now the last and the final step proceed to Specify the DB details such as the instance size, engine version as shown in the below screenshot.

Migrating MySQL to RDS/Aurora with Xtrabackup
Migrating MySQL to RDS/Aurora with Xtrabackup

Next choose the backup retention, VPC and security group for accessing the DB instance.

Now click next your instance is getting ready

Migrating MySQL to RDS/Aurora with Xtrabackup

It took around some 20 mins to get instance ready

Migrating MySQL to RDS/Aurora with Xtrabackup

In the above restore we have just used data, from sysbench so it shouldn’t be an issue, let’s check the data consistency, By checking the count between the source instance and the restored RDS instance as shown below.

Migrating MySQL to RDS/Aurora with Xtrabackup

Migrating MySQL to RDS/Aurora with Xtrabackup

Hope you have enjoyed and learned, Also share your much-valued feedback.

Need assistance with your MySQL cloud migration? Mydbops, our open-source database management service, offers comprehensive MySQL support, including Xtrabackup expertise and performance optimization. Let our team of database specialists ensure a smooth and efficient migration to the cloud. Contact Mydbops today!

{{cta}}

Image Courtesy: Photo by Gareth Davies on Unsplash

No items found.

About the Author

Mydbops

Subscribe Now!

Subscribe here to get exclusive updates on upcoming webinars, meetups, and to receive instant updates on new database technologies.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.