Created
August 18, 2012 04:35
-
-
Save barraponto/3384457 to your computer and use it in GitHub Desktop.
Automatically loads a database snapshot on git checkout. Useful for git bisects.
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 | |
# 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 | |
# 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; } | |
path="$( cd `drush dd` ; realpath $DRUPAL_DUMP_PATH 2>&1 )" | |
if [ -r "${path}/${filename}.gz" ]; then gunzip -c "${path}/${filename}.gz" | `drush sql-connect`; else echo "Can't find ${path}/${filename}.gz. Auto-recovery aborted."; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment