Drush Commands
Basic Drush
// Download a module or theme
drush dl cck
// Enable module or theme
drush en cck
// clear cache all, don't need sudo
drush cc all
// Get help message on command
drush help pm-update
// List site aliases
drush sa
// Get status on particular site, via site-alias
drush @math status
Advanced Drush
Using Drush to sync a remote server
Sync Dev Server with Staging Server
// drush core-rsync <source> <destination>
drush core-rsync @dev @stage
- see for full documentation:
http://drush.ws/#core-rsync
Download drushextras
drush dl drush_extras
Drush pushkey
This command creates a ssl public/private key in your home directory and copies the public key to a remote server. Subsequent drush commands will use this public/private key for authentication.
// okay substitute your username for "boris" and your server for "badinoff.com"
drush pushkey boris@badinoff.com
Drush Git Backup
Install DGB
cd <drush directory>/commands/
git clone https://github.com/scor/dgb.git
Setup DGB for a site
# from DRUPAL_ROOT
# cd up one directory
cd ..
# create directory for backed up database
mkdir databases
# initialize a git repository
git init
Back up Site
cd <DRUPAL_ROOT>
drush dgb-backup
What is in DGB Archive
The DGB instance directory is the directory up from your DRUPALROOT.
each site’s db dump is in databases/
Database dump for default is in databases/default.sql
There is a Git repository of your site’s files
# from DRUPAL_ROOT cd into the DGB instance directory
cd ..
# see list of git commits
git log
# see what files have changed since last call to drush dgb-backup
git status
Clone the Site for development
# from DRUPAL_ROOT
cd ../..
# create a dev directory parallel to other site
mkdir dev
cd dev
git clone <path to dgb instance>
# create a new branch called "my-dev-branch"
git branch my-dev-branch
# checkout the new dev branch
git checkout my-dev-branch
# now create a new database with the database dump
# change <dbuser>, <dbpasswd>, <devdbname> and <path-to-dgb-instance>
# and also the substitute default.sql for the name of your databasedump
mysql -u <dbuser> -p <dbpasswd> <devdbname> < <path-to-dgb-instance>/databases/default.sql
# now finally update settings.php to point to your dev database
vim sites/default/settings.php
# finally check that there is an .htaccess file in your new dev
# <DRUPAL_ROOT> if not, copy it over from the cloned siteF
Another Way to Copy @live to @dev
# Core-rsync copies all of the files from one site instance to another.
# The first time you sync you can use --include-conf option to copy settings.php.
drush core-rsync @live @dev --include-conf
# Next change database settings to use @dev database.
vi <document-root>/sites/default/settings.php
# After first sync use w/out --include-conf and it will preserve the existing settings.php.
drush core-rsync @live @dev
# Sync databases.
drush sql-sync @live @dev
Database dump for default is in databases/default.sql
There is a Git repository of your site’s files
# from DRUPAL_ROOT cd into the DGB instance directory
cd ..
# see list of git commits
git log
# see what files have changed since last call to drush dgb-backup
git status
Clone the Site for development
# from DRUPAL_ROOT
cd ../..
# create a dev directory parallel to other site
mkdir dev
cd dev
git clone <path to dgb instance>
# create a new branch called "my-dev-branch"
git branch my-dev-branch
# checkout the new dev branch
git checkout my-dev-branch
# now create a new database with the database dump
# change <dbuser>, <dbpasswd>, <devdbname> and <path-to-dgb-instance>
# and also the substitute default.sql for the name of your databasedump
mysql -u <dbuser> -p <dbpasswd> <devdbname> < <path-to-dgb-instance>/databases/default.sql
# now finally update settings.php to point to your dev database
vim sites/default/settings.php
# finally check that there is an .htaccess file in your new dev
# <DRUPAL_ROOT> if not, copy it over from the cloned siteF
Another Way to Copy @live to @dev
# Core-rsync copies all of the files from one site instance to another.
# The first time you sync you can use --include-conf option to copy settings.php.
drush core-rsync @live @dev --include-conf
# Next change database settings to use @dev database.
vi <document-root>/sites/default/settings.php
# After first sync use w/out --include-conf and it will preserve the existing settings.php.
drush core-rsync @live @dev
# Sync databases.
drush sql-sync @live @dev