Search code examples
mysqlamazon-web-servicesgoogle-cloud-sqlrds

Import/Export mysql between two remote hosts over SSH


I'm using RDS on Amazon and need a way to import a large database of over 3TB over to Google SQL Cloud.

The biggest problem here is time -- I need this to happen quickly. It doesn't feel right having to compress 3TB of data into a single .sql file, move it to an s3 bucket and then import that huge file into Google - which is what they seem to prefer you to do.

Apparently AWS doesn't let you create an image and move it to S3, so I can't then import that image over into Google.

Also, there doesn't seem to be a method to do a mysqldump / import from a remote sever via the Google Cloud Console.

Has anybody faced the same issue and is there a quick a direct way of approaching this?


Solution

  • After many hours of searching around, I was able to use an exising AWS instance to act as a proxy between the two remote SQL servers.

    After allowing access to the Google SQL server (entering the IP for an AWS machine under the 'authorization' tab) you can connect to both remote servers and use something like this to directly copy each database table over:

    mysqldump -h yourdatabase.rds.amazonaws.com -u user -ppassword awsdbtable --compress --single-transaction | mysql --host=YourGoogleSQL_IP --user=dbuser --password=dbpassword googledbtable