Skip to content

Instantly share code, notes, and snippets.

@puckbag
Created August 1, 2012 21:11
Show Gist options
  • Save puckbag/3230791 to your computer and use it in GitHub Desktop.
Save puckbag/3230791 to your computer and use it in GitHub Desktop.
Drupal Sync Down (From Production to Development)
#!/bin/sh
SSH=user@host
DATABASE=xxxxxx
USERNAME=xxxxxx
PASSWORD=xxxxxx
WEBROOT=/var/www/html/
LOCAL_DATABASE=xxxxxx
LOCAL_USERNAME=xxxxxx
LOCAL_PASSWORD=xxxxxx
LOCAL_WEBROOT=/var/www/vhosts/xxxxxx/htdocs/
# dump remote into local
ssh $SSH "mysqldump -u'$USERNAME' -p'$PASSWORD' '$DATABASE' | gzip" | gzip -d | \
mysql -u"$LOCAL_USERNAME" -p"$LOCAL_PASSWORD" "$LOCAL_DATABASE"
# sync remote down to local, exclude sites/
rsync -avz -e ssh $SSH:"$WEBROOT" "$LOCAL_WEBROOT" --exclude 'sites/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment