introduction to drush - drupalcamp london 2014
DESCRIPTION
Presentation at DrupalCamp London 2014 about using Drush, the Drupal shell. Audio/video available here: http://youtu.be/XB4of9ev4TsTRANSCRIPT
Introduction to Drush$ @anthonyalbertyn$ #dclondon$ z
What is Drush? Drush = Drupal Shell Command line interface Scripting environment that can be
extended Toolbox of useful utilities
Why use Drush? Can be massively more productive
than using a GUI Access drush commands supplied
by contrib modules
What can Drush do? Perform tasks with modules, themes,
profiles, translations and core:- download, enable, update, - disable and uninstall
Add, remove and manage users
What else can Drush do? Various admin tasks like
clear cache, run cron, re-index search Database related tasks like
backup database, migrate databases between different sites
What do we need touse Drush locally ?
Install Drush on your pc/mac Terminal / Windows Command
Processor (command prompt)
What do we need touse Drush remotely ? Install Drush on server SSH client
- for Mac use Terminal- for Windows install and use PuTTY
Options for installing Drush Use PEAR (preferred way) Install Drush manually There are other ways too Instructions for various environments:
http://drupal.org/node/1791676
Two ways to use Drush Navigate to your Drupal root directory
on local or remote site and type:drush [command]
Setup a Drush site alias and locally from anywhere in Terminal type:drush @[alias] [command]
List useful Drush commands
drush help
Download modules
drush dl omega
drush dl date context ds
Enable modules
drush en omega
drush en date context ds
Disable modules
drush dis omega
drush dis date context ds
Uninstall modules
drush pm-uninstall omega
drush pm-uninstall date ds
List modules and themes on site
drush pm-list
More info on module in site
drush pm-info context
Clear the cache
drush cc
drush cc all
Run cron on your site
drush cron
Search status – how many items still need indexing
drush search-status
Search index – index remaining search items without wiping out the existing index
drush search-index
Search re-index – force the search index to be re-built
drush search-reindex
List available site aliases
drush sa
Show status of a site
drush status
drush @alias status
Get info about an existing user
drush user-information usernamedrush user-information useriddrush user-information useremail
Block and unblock a user
drush user-block username
drush user-unblock username
Create a new user
drush user-create username--mail=“[email protected]” --password=“password123”
Give a user a role
drush user-add-role ”user role” username
Set a new password for a user
drush user-password username --password=“newpass123”
One-time login link for a user
drush uli username
drush @alias uli username
Delete a user account
drush user-cancel username
Update drupal core and contrib modules to latest recommended releases and apply pending database updates
drush up
Dump database into sql file
drush sql-dump > /path/to/
myfile.sql
Copy entire database from one environment to another
drush sql-sync @site1 @site2
Sync files folder content from one site to another
drush rsync @site1:%files @site2:%files
More info on deploying sites
drush help site-aliasdrush help sql-sync drush help rsync
Setup and use Drush aliases Blog post about Drush aliases
http://www.astonishdesign.com/blog/drush-aliases-what-why-and-how
Synchronise and deploy siteshttp://drupal.org/node/670460
Example of valid alias statementshttp://drush.ws/examples/example.aliases.drushrc.php
Manual installation on Mac Download Drush from GitHub
http://github.com/drush-ops/drush Unpack into home directory
/Users/username Grant yourself file execution permissionschmod u+x /Users/username/drush/drush
Manual installation on Mac Tell OS X where to find Drush: Add drush path to your $PATH
- via Terminal- or Bash- or Profile
OR create a symbolic link to the path
Mac – add Drush to path Example:
In directory /Users/username,edit .profile and add:export PATH=$PATH:/Users/username/drush/drush
Mac – create symbolic link Example sym link:cd /usr/binln –s /Users/username/drush/drush
More info mac installation:http://drupal.org/node/1674222http://drupal.org/node/508450
Test that Drush works Open your Terminal and typedrush --version
To display a list of helpful drush commands:drush help
Learning resources Drush User’s Guide (book)
Novillo, J.P, Packt Publishing, 2012ISBN 978-1-84951-798-0
Drush for Humans – SANDcamp 2013Presenter: Jon Peckhttps://www.youtube.com/watch?v=Pp6UofwFMDw
Learning resources Drush optimizations for your
development workflow – DrupalCon Prague 2013Presenters: varioushttps://prague2013.drupal.org/session/drush-optimizations-your-development-workflow
Drush resources Drush commands
http://www.drush.org
Drush GitHub projecthttp://github.com/drush-ops/drush
Drush Windows installerhttp://drush.ws/drush_windows_installer
Drush API docshttp://api.drush.ws
About me @anthonyalbertyn Front-end web developer Co-founder and organiser of
#drupalcambs http://www.meetup.com/drupalcambs