D8 dump/restore scripts - relies on Drush (which is currently broken on D8)
#!/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
#!/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