2023-12-01 21:52:30 +00:00
|
|
|
#!/bin/bash
|
2023-12-05 22:07:08 +00:00
|
|
|
set -euo pipefail
|
|
|
|
# ~SCRIPT~ update.sh
|
|
|
|
# * Pass in a path to drush, or use a default:
|
|
|
|
# * Runs post-deploy commands to update Drupal
|
|
|
|
|
2023-12-01 21:52:30 +00:00
|
|
|
# Confirmed with echo `pwd` that as long as we use via composer it's always in
|
|
|
|
# /var/www/html (aka the project root).
|
|
|
|
proj_dir="$(cd $(dirname ${0})/../ && pwd)" # Parent of this script folder.
|
|
|
|
[ "$proj_dir" != "/var/www/html" ] && { echo "Script running from unexpected path - are you running within ddev, as you should?"; exit 1; }
|
2023-12-05 22:07:08 +00:00
|
|
|
backup_file="$(date +%Y%m%dT%H%M%S)_pre_pull.sql.gz"
|
2023-12-01 21:52:30 +00:00
|
|
|
[ ! -d /var/www/html/backups ] && mkdir /var/www/html/backups || true
|
2023-12-05 22:07:08 +00:00
|
|
|
echo ">> Backing up current db to backups/${backup_file}..."
|
|
|
|
drush sql-dump --gzip > /var/www/html/backups/${backup_file}
|
|
|
|
echo ">> Dropping local db..."
|
2023-12-01 21:52:30 +00:00
|
|
|
drush -y sql-drop
|
2023-12-05 22:07:08 +00:00
|
|
|
echo ">> Pulling db from live into local..."
|
|
|
|
drush -y sql-sync --structure-tables-key=common @live @self
|
|
|
|
echo ">> Pulling files from live into local..."
|
|
|
|
drush -y rsync --exclude-paths=css:js:php @live:%files @self:%files
|
|
|
|
echo ">> Local cache reload..."
|
|
|
|
drush cr
|
2023-12-01 21:52:30 +00:00
|
|
|
echo "Done"
|