Created
March 1, 2016 13:54
-
-
Save Veve2/9a60305e0724c05e6de3 to your computer and use it in GitHub Desktop.
Script to dump a mysql database from the parameters of a Symfony project (script from A.L, http://stackoverflow.com/a/35724475/4074148)
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 | |
# See http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in/23905052#23905052 | |
ROOT=$(readlink -f $(dirname "$0")) | |
cd $ROOT | |
# Get database parameters | |
dbname=$(grep "database_name" ./app/config/parameters.yml | cut -d " " -f 6) | |
dbuser=$(grep "database_user" ./app/config/parameters.yml | cut -d " " -f 6) | |
dbpassword=$(grep "database_password" ./app/config/parameters.yml | cut -d " " -f 6) | |
filename="$(date '+%Y-%m-%d_%H-%M-%S').sql" | |
echo "Export $dbname database" | |
mysqldump -B "$dbname" -u "$dbuser" --password="$dbpassword" > "$filename" | |
echo "Output file :" | |
ls -lh "$filename" |
Author
Veve2
commented
Mar 1, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment