Skip to content

Instantly share code, notes, and snippets.

@ianblenke
Created July 30, 2015 13:46
Show Gist options
  • Save ianblenke/ea90a58a734aaf2ac0d2 to your computer and use it in GitHub Desktop.
Save ianblenke/ea90a58a734aaf2ac0d2 to your computer and use it in GitHub Desktop.
Processing the DATABASE_URL for an elasticbeanstalk app to do a mysqldump
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