Last active
October 12, 2017 22:06
-
-
Save alphaJohnny/13ef4a1223b164a9c7c7d8a228d737e4 to your computer and use it in GitHub Desktop.
MySQLDump AWS RDS to Local using compression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Export MySQL data from AWS using SSH | |
#Create a databases.txt file with one line per database. Can be done by piping out "show databases" command | |
#TODO fix the gzip error; till then use mysql-dump-from-rds-command-creator | |
SSH-USER=ubuntu | |
SSH-SERVER=123.123.123.123 | |
SSH-KEYFILE=server.pem | |
DB-SERVER=mysql.czpoly.1.east.amazonaws.com | |
DB-USER=admin | |
DB-PASS=admin | |
while read d; do | |
echo ssh -i \"$SSH-KEYFILE\" $SSH-USER@$SSH-SERVER \"mysqldump -u$DB-USER -p$DB-PASS -h$DB-SERVER $d | gzip -9\" | gzip -d > $d.sql | |
done <databases.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment