Created
December 2, 2017 17:28
-
-
Save oksana-c/ff37782216faf577d2b6e64b07775342 to your computer and use it in GitHub Desktop.
Automated Drupal DB Pull from the server with Drush sql-dump
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
#!/usr/bin/env bash | |
# This script can be run from any location. | |
# - sh automated_dbpull.sh | |
# SSH to the server using SSH key. | |
ssh -tt -i ~/.ssh/id_rsa YOURUSERNAME@SERVER << EOF | |
cd /var/www/sites/SITEDIRECTORY/www; | |
drush sql-dump --result-file=../build/DBNAMEOFCHOICE.sql --gzip --structure-tables-key=cache,cache_*,history,search_*,sessions,watchdog; | |
exit; | |
EOF | |
echo "Exited SSH"; | |
scp YOURUSERNAME@SERVER:/var/www/sites/SITEDIRECTORY/build/DBNAMEOFCHOICE.sql.gz ~/Sites/LOCALSITE/build/ref_db; | |
echo "DB downloaded." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment