Created
July 30, 2015 13:46
-
-
Save ianblenke/ea90a58a734aaf2ac0d2 to your computer and use it in GitHub Desktop.
Processing the DATABASE_URL for an elasticbeanstalk app to do a mysqldump
This file contains hidden or 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
DATABASE_URL=$(sudo /opt/elasticbeanstalk/bin/get-config environment | jq .DATABASE_URL) | |
fields=( $(echo $DATABASE_URL | sed -e 's/^"mysql2:\/\/\([^:]*\):\([^@]*\)@\([^:]*\):\([^/]*\)\/\([^\?]*\)\?.*$/\1 \2 \3 \4 \5/') ) | |
docker exec -ti $(docker ps -a | grep web | awk '{print $1}') mysqldump -h ${fields[2]} -u ${fields[0]} --password="${fields[1]}" -P ${fields[3]} ${fields[4]} > ${fields[4]}.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment