Last active
October 16, 2017 11:33
-
-
Save andriyun/8ee0c58d32447d6ed8eb9610aea6d71c to your computer and use it in GitHub Desktop.
Fetch db from dev to local
This file contains hidden or 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/sh | |
PROJECT_SITENAME="example.com" | |
DRUPAL_ROOT="/path/to/drupal/root_folder" | |
DUMP_FILE_NAME="${PROJECT_SITENAME}_db_$(date +%Y%m%d).sql.gz" | |
LOCAL_ENV_WRAPPER="sh -c" | |
# For dockerized env. | |
#LOCAL_ENV_WRAPPER="docker-compose exec php sh -c" | |
SSH_CRED="user@remote_host" | |
ssh $SSH_CRED "drush --uri=$PROJECT_SITENAME --root=$DRUPAL_ROOT sql-dump | gzip -9 > ~/$DUMP_FILE_NAME" | |
scp $SSH_CRED:~/$DUMP_FILE_NAME ./public_html | |
ssh $SSH_CRED "rm ~/$DUMP_FILE_NAME" | |
$LOCAL_ENV_WRAPPER "whoami" | |
$LOCAL_ENV_WRAPPER "gzip -d < $DUMP_FILE_NAME | drush --uri=$PROJECT_SITENAME sqlc" | |
# Below you can specify all required command for local env. | |
$LOCAL_ENV_WRAPPER "drush --uri=$PROJECT_SITENAME cc all" | |
$LOCAL_ENV_WRAPPER "drush --uri=$PROJECT_SITENAME vset file_temporary_path '../tmp'" | |
$LOCAL_ENV_WRAPPER "drush --uri=$PROJECT_SITENAME en stage_file_proxy -y" | |
$LOCAL_ENV_WRAPPER "drush --uri=$PROJECT_SITENAME vset stage_file_proxy_origin http://$PROJECT_SITENAME" | |
$LOCAL_ENV_WRAPPER "rm $DUMP_FILE_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment