Skip to content

Instantly share code, notes, and snippets.

@barraponto
Created August 17, 2012 23:57
Show Gist options
  • Save barraponto/3383529 to your computer and use it in GitHub Desktop.
Save barraponto/3383529 to your computer and use it in GitHub Desktop.
Automatically dump Drupal database on commit
#! /bin/bash
# Set overridable filename format
: ${DRUPAL_DUMP_FORMAT:="%at-%h"}
filename="$( git log -n 1 --format=${DRUPAL_DUMP_FORMAT} ).sql" # see git help log for more on git formats
# Set overridable path
: ${DRUPAL_DUMP_PATH:="."} # path, relative to drupal root
path="$( cd `drush dd` ; realpath $DRUPAL_DUMP_PATH 2>&1 )"
# Check if drush is available
command -v drush > /dev/null 2>&1 || { echo >&2 "I require drush but it's not installed. Please check http://drush.ws"; exit 1; }
drush sql-dump --result-file="${path}/${filename}" --gzip
@barraponto
Copy link
Author

See companion hook https://gist.github.com/3384457

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