Skip to content

Instantly share code, notes, and snippets.

@alexislefebvre
Created August 8, 2016 11:06
Show Gist options
  • Select an option

  • Save alexislefebvre/0b2d93b2c78a064b49a6c912deff5ab8 to your computer and use it in GitHub Desktop.

Select an option

Save alexislefebvre/0b2d93b2c78a064b49a6c912deff5ab8 to your computer and use it in GitHub Desktop.

Revisions

  1. alexislefebvre created this gist Aug 8, 2016.
    21 changes: 21 additions & 0 deletions symfony_mysqldump.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/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"