My sync2dev script on Mac

We could use the several drush + shell commands manually but why not script this? This is how I do this on Mac OSX which has it's own quirks.

Place the follow script into the parent dir of your drupal root as sync2dev. This way you can control all you DEV sites in a similar way. ../sync2dev

Content of sync2dev by https://twitter.com/ClemensTolboom

# Show commands executed
set -x

# --simulate does not work
# DRUSH_OPTS="--yes --verbose --simulate"

# Say yes to the dress
DRUSH_OPTS="--yes"

# --no does not work for registry-rebuild or features-status
# DRUSH_OPTS="--no"

# simulate seems gone as an option
# DRUSH_OPTS="--simulate"

# Source alias
DRUSH_ALIAS_REMOTE=@site.stage
# DRUSH_ALIAS_REMOTE=@site.live

# Target
DRUSH_ALIAS_DEV=@site.dev
DRUPAL_ROOT=/Users/clemens/Sites/my-site/dev/www

# Where to find the files
SITE_DIR=default

# What user and group to set
USER=clemens
GROUP=_www

# Make sure sudo command is executable later on
sudo echo "Thanks."

# Sync database
drush $DRUSH_OPTS $DRUSH_ALIAS_DEV sql-drop
drush $DRUSH_OPTS sql-sync $DRUSH_ALIAS_REMOTE $DRUSH_ALIAS_DEV

# Fix before receiving files
sudo chown -R $USER $DRUPAL_ROOT/sites/$SITE_DIR/files
sudo chown -R $USER $DRUPAL_ROOT/sites/$SITE_DIR/private
sudo chgrp -R $GROUP $DRUPAL_ROOT/sites/$SITE_DIR/files

# Get the files
drush $DRUSH_OPTS rsync $DRUSH_ALIAS_REMOTE:%files $DRUSH_ALIAS_DEV:%files

# Fix after receiving
sudo chown -R $USER $DRUPAL_ROOT/sites/$SITE_DIR/files
sudo chown -R $USER $DRUPAL_ROOT/sites/$SITE_DIR/private
sudo chgrp -R $GROUP $DRUPAL_ROOT/sites/$SITE_DIR/files

# Drupal 7 variant of cache-rebuild
drush $DRUSH_OPTS $DRUSH_ALIAS_DEV registry-rebuild

# Login to site
drush $DRUSH_OPTS $DRUSH_ALIAS_DEV user-login

# Make sure drush finds the features drush extension
drush cc drush

# List features with changes
drush $DRUSH_OPTS $DRUSH_ALIAS_DEV features-list --state=db