Skip to content

Instantly share code, notes, and snippets.

@alexislefebvre
Created August 8, 2016 11: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 alexislefebvre/0b2d93b2c78a064b49a6c912deff5ab8 to your computer and use it in GitHub Desktop.
Save alexislefebvre/0b2d93b2c78a064b49a6c912deff5ab8 to your computer and use it in GitHub Desktop.
#!/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"
@Fuzzyma
Copy link

Fuzzyma commented Aug 8, 2016

wget -O - http://foo.bar/pathToScript.sh | bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment