Skip to content

Instantly share code, notes, and snippets.

@davidneedham
Last active March 17, 2016 13:06
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save davidneedham/9264d2bb4a8b483907f6 to your computer and use it in GitHub Desktop.
Save davidneedham/9264d2bb4a8b483907f6 to your computer and use it in GitHub Desktop.
Pantheon Development Workflow (pdw): Commands to improve your Pantheon to local development experience. Just copy these commands into your .bash_profile or .bashrc, update the pdw-auth command to use your credentials, install Terminus (https://github.com/pantheon-systems/cli/wiki/Installation), and go!
#------------------------------------------
# PANTHEON DEVELOPMENT WORKFLOW v1.01
# Using the Pantheon CLI (terminus) v0.71
#------------------------------------------
# Authenticate with Pantheon. The first step, most of the time.
# This is a little insecure, as it lists your password here. But it's convenient.
alias pdw-auth='terminus auth login YOURPANTHEONEMAILADDRESS --password=YOURPANTHEONPASSWORD'
# Update your local Pantheon site aliases
alias pdw-sa='terminus sites aliases'
# Quickly run a drush command via terminus
# pdw-drush SITENAME ENVIRONMENT DRUSHCOMMAND DRUSHARGUMENT
# eg. pdw-drush mysite dev en
function pdw-drush() {
terminus drush $3 $4 $5 $6 $7 --site=$1 --env=$2 --bash
}
# Generate the uli for a particular Pantheon site
function pdw-uli() {
terminus drush uli $3 --site=$1 --env=$2
}
# Clear the cache a particular Pantheon site
function pdw-cc() {
terminus drush cc all --site=$1 --env=$2
}
# Create a backup on the server
function pdw-backup() {
terminus site backups create --element=$3 --site=$1 --env=$2
}
# Pull the Pantheon database into the local environment
function pdw-pull-db() {
pdw-backup $1 $2 'database';
OUTPUT=`terminus site backups get --element=database --site=$1 --env=$2 --latest`
OUTPUT=`echo $OUTPUT | grep -o "https://pantheon-backups.*"`
wget $OUTPUT -O /tmp/most-recent-terminus-export.sql.gz
gunzip < /tmp/most-recent-terminus-export.sql.gz | `drush @self sql-connect`
}
# Pull the Pantheon files into the local environment
function pdw-pull-files() {
drush -y -r . rsync --progress @pantheon.$1.$2:%files @self:sites/default
}
# Sync local environment with a particular Pantheon environment
function pdw-pull () {
git pull &&
echo 'CODE SYNC FROM PANTHEON COMPLETE' &&
echo '==================================' &&
pdw-pull-db $1 $2 &&
echo 'DB SYNC FROM PANTHEON COMPLETE' &&
echo '==================================' &&
pdw-pull-files $1 $2 &&
echo 'FILES SYNC FROM PANTHEON COMPLETE' &&
echo '==================================' &&
drush updb -y &&
echo 'DATABASE UPDATES COMPLETE' &&
echo '=================================='
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment