Saturday, November 30, 2013

Backup AWS MySQL RDS Instance and Restore on Remote Machine

Was looking for a way to back up MySQL RDS to local copy to do some work a bit faster offline.

If you want to use replication to move data from one database to another - if you have the appropriate network access to do so:

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Procedural.Exporting.NonRDSRepl.html

I used another option since my database was pretty small and I run my database access through a bastion host.

I have set up network access to RDS database from the bastion host and installed MySQL Workbench on it. I connected to my RDS instance in MySQL workbench, then click on "Data Export" in left menu and followed the prompts to dump a file.

Then I compressed and copied the dump files to my local machine.

Then reversed the process with local copy of MySQL workbench and choose "Data Import/Restore" on the local machine.

This is a quick hack. If doing this repeatedly would optimize and automate.