Last active
December 27, 2015 18:28
-
-
Save yched/7369557 to your computer and use it in GitHub Desktop.
D8 dump/restore scripts - relies on Drush (which is currently broken on D8)
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 | |
# TO CONFIGURE | |
DRUSH='/usr/local/bin/drush' | |
DUMP_SUBFOLDER='dumps' | |
DUMP_NAME=$1 | |
DRUPAL_ROOT=`$DRUSH st drupal_root --format=list` | |
DRUPAL_CONFIG=`$DRUSH st active_config_directory_path --format=list` | |
DUMP_DIR="$DRUPAL_ROOT/$DUMP_SUBFOLDER/$DUMP_NAME" | |
CONFIG_DUMP_DIR="$DUMP_DIR/config" | |
# Cleanup previous dump | |
rm -rf $DUMP_DIR | |
mkdir -p $DUMP_DIR | |
# Dump DB | |
$DRUSH sql-dump --result-file="$DUMP_DIR/dump.sql" | |
# Dump config | |
cp -R $DRUPAL_CONFIG $CONFIG_DUMP_DIR |
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 | |
# TO CONFIGURE | |
DRUSH='/usr/local/bin/drush' | |
DUMP_SUBFOLDER='dumps' | |
DUMP_NAME=$1 | |
DRUPAL_ROOT=`$DRUSH st drupal_root --format=list` | |
DRUPAL_CONFIG=`$DRUSH st active_config_directory_path --format=list` | |
DUMP_DIR="$DRUPAL_ROOT/$DUMP_SUBFOLDER/$DUMP_NAME" | |
SQL_DUMP="$DUMP_DIR/dump.sql" | |
CONFIG_DUMP_DIR="$DUMP_DIR/config" | |
# Restore DB | |
if [ -f $SQL_DUMP ] ; then | |
$DRUSH sql-drop --yes | |
SQL_CONNECT=`$DRUSH sql-connect` | |
$SQL_CONNECT < $SQL_DUMP | |
echo "DB restored" | |
else | |
echo "No DB dump found - skipping" | |
fi | |
# Restore config | |
if [ -d $CONFIG_DUMP_DIR ] ; then | |
sudo chmod g+w $DRUPAL_CONFIG/.. | |
sudo rm -rf $DRUPAL_CONFIG | |
cp -R $CONFIG_DUMP_DIR $DRUPAL_CONFIG | |
sudo chmod g+w $DRUPAL_CONFIG/*.yml | |
echo "Config restored" | |
else | |
echo "No config dump found - skipping" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment