Created
October 12, 2017 22:10
-
-
Save alphaJohnny/6d5bb0cfd6c616f9b47538dd16bacdb4 to your computer and use it in GitHub Desktop.
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 | |
#Usage: ./mysql-dump-from-rds-command-creator.bat > dump_commands.bat | |
#Usage2: ./dump_commands.bat | |
#Expects databases.txt newline delimited list of all databases | |
#Goal: Export MySQL data from AWS using SSH | |
#Step1: Create a databases.txt file with one line per database. Can be done by piping out "show databases" command | |
SSHUSER=ubuntu | |
SSHSERVER=server.com | |
SSHKEYFILE="/Users/am/Library/Mobile Documents/com~apple~CloudDocs/Keys/web-serv.pem" | |
DBSERVER=dbserver.us-east-1.rds.amazonaws.com | |
DBUSER=admin | |
DBPASS=admin | |
filename='databases.txt' | |
exec 4<$filename | |
echo "#!/bin/bash" | |
while read -u4 p ; do | |
echo "ssh -i \"$SSHKEYFILE\" $SSHUSER@$SSHSERVER \"mysqldump -u$DBUSER -p$DBPASS -h$DBSERVER "$p" | gzip -9\" | gzip -d > "$p.sql | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment