valentine94
10/15/2019 - 6:27 PM

Reinstall local site D7

#!/usr/bin/env bash

importDatabase() {
  echo -n "Importing database dump..."
  $(drush sql-connect) < ../dump.sql
  echo "Done!"
}
dropDatabase() {
  # 3 times to ignore possible errors.
  echo -n "Dropping database..."
  for i in 1 2 3
  do
    drush sql-drop --yes &> /dev/null
  done
  echo "Done!"
}
cacheRebuild() {
  drush cc all &> /dev/null
}

# Drop existing database and import database dump.
dropDatabase && importDatabase
# Clear the caches.
cacheRebuild
# Perform update.php.
drush updb --yes; drush updb --yes
# Clear the caches.
cacheRebuild
# Clear the caches.
cacheRebuild
# Run update.php again.
drush updb --yes
# Update admin password.
drush upwd admin --password=admin
# Enable devel and dblog.
drush en devel, dblog -y