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

Download drush_extras

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

# cd up one directory
cd ..
# create directory for backed up database
mkdir databases
# initialize a git repository
git init

Back up Site

drush dgb-backup

What is in DGB Archive

The DGB instance directory is the directory up from your DRUPAL_ROOT.

each site's db dump is in databases/<site-name>.sql

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

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


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.