Skip to content

Instantly share code, notes, and snippets.

@alphaJohnny
Last active October 12, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alphaJohnny/13ef4a1223b164a9c7c7d8a228d737e4 to your computer and use it in GitHub Desktop.
Save alphaJohnny/13ef4a1223b164a9c7c7d8a228d737e4 to your computer and use it in GitHub Desktop.
MySQLDump AWS RDS to Local using compression
#!/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