Mysql – Can you restore a MySQL dump file from an S3 bucket to an RDS instance

amazon s3MySQL

I'm investigating running regular MySQL dumps to an S3 bucket as part of a disaster recovery strategy (partly spurred by the current zero cost of inbound data transfer!). In the event of a disaster, I would want to restore the dump file from S3 to a new RDS instance. Despite extensive searching, I can't find any examples of this. Does anyone know if this is possible?

To give a bit of context, it's a 500GB write-heavy read-light 24×7 MySQL database. I'm planning to use MySQL replication to a slave, which we can then take dumps from to send to S3 in case of a host failure (we use the same hosting provider for the replication master and slave, although they are in different data centres).

Best Answer

You can use the AWS CLI tool and STDIN on the CLI ("-") for this:

mysql -u db_user -ppassword database_name < aws s3 cp s3://mysqldump_bucket_name/mysqldump.sql -

The - part of the aws s3 cp command pipes the output to STDOUT which is read by mysql.