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
![Page 1: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/1.jpg)
Introduction to Drush$ @anthonyalbertyn$ #dclondon$ z
![Page 2: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/2.jpg)
What is Drush? Drush = Drupal Shell Command line interface Scripting environment that can be
extended Toolbox of useful utilities
![Page 3: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/3.jpg)
Why use Drush? Can be massively more productive
than using a GUI Access drush commands supplied
by contrib modules
![Page 4: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/4.jpg)
What can Drush do? Perform tasks with modules, themes,
profiles, translations and core:- download, enable, update, - disable and uninstall
Add, remove and manage users
![Page 5: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/5.jpg)
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
![Page 6: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/6.jpg)
What do we need touse Drush locally ?
Install Drush on your pc/mac Terminal / Windows Command
Processor (command prompt)
![Page 7: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/7.jpg)
What do we need touse Drush remotely ? Install Drush on server SSH client
- for Mac use Terminal- for Windows install and use PuTTY
![Page 8: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/8.jpg)
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
![Page 9: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/9.jpg)
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]
![Page 10: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/10.jpg)
List useful Drush commands
drush help
![Page 11: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/11.jpg)
Download modules
drush dl omega
drush dl date context ds
![Page 12: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/12.jpg)
Enable modules
drush en omega
drush en date context ds
![Page 13: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/13.jpg)
Disable modules
drush dis omega
drush dis date context ds
![Page 14: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/14.jpg)
Uninstall modules
drush pm-uninstall omega
drush pm-uninstall date ds
![Page 15: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/15.jpg)
List modules and themes on site
drush pm-list
![Page 16: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/16.jpg)
More info on module in site
drush pm-info context
![Page 17: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/17.jpg)
Clear the cache
drush cc
drush cc all
![Page 18: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/18.jpg)
Run cron on your site
drush cron
![Page 19: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/19.jpg)
Search status – how many items still need indexing
drush search-status
![Page 20: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/20.jpg)
Search index – index remaining search items without wiping out the existing index
drush search-index
![Page 21: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/21.jpg)
Search re-index – force the search index to be re-built
drush search-reindex
![Page 22: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/22.jpg)
List available site aliases
drush sa
![Page 23: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/23.jpg)
Show status of a site
drush status
drush @alias status
![Page 24: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/24.jpg)
Get info about an existing user
drush user-information usernamedrush user-information useriddrush user-information useremail
![Page 25: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/25.jpg)
Block and unblock a user
drush user-block username
drush user-unblock username
![Page 27: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/27.jpg)
Give a user a role
drush user-add-role ”user role” username
![Page 28: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/28.jpg)
Set a new password for a user
drush user-password username --password=“newpass123”
![Page 29: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/29.jpg)
One-time login link for a user
drush uli username
drush @alias uli username
![Page 30: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/30.jpg)
Delete a user account
drush user-cancel username
![Page 31: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/31.jpg)
Update drupal core and contrib modules to latest recommended releases and apply pending database updates
drush up
![Page 32: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/32.jpg)
Dump database into sql file
drush sql-dump > /path/to/
myfile.sql
![Page 33: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/33.jpg)
Copy entire database from one environment to another
drush sql-sync @site1 @site2
![Page 34: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/34.jpg)
Sync files folder content from one site to another
drush rsync @site1:%files @site2:%files
![Page 35: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/35.jpg)
More info on deploying sites
drush help site-aliasdrush help sql-sync drush help rsync
![Page 36: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/36.jpg)
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
![Page 37: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/37.jpg)
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
![Page 38: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/38.jpg)
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
![Page 39: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/39.jpg)
Mac – add Drush to path Example:
In directory /Users/username,edit .profile and add:export PATH=$PATH:/Users/username/drush/drush
![Page 40: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/40.jpg)
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
![Page 41: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/41.jpg)
Test that Drush works Open your Terminal and typedrush --version
To display a list of helpful drush commands:drush help
![Page 42: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/42.jpg)
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
![Page 43: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/43.jpg)
Learning resources Drush optimizations for your
development workflow – DrupalCon Prague 2013Presenters: varioushttps://prague2013.drupal.org/session/drush-optimizations-your-development-workflow
![Page 44: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/44.jpg)
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
![Page 45: Introduction to Drush - DrupalCamp London 2014](https://reader035.vdocuments.site/reader035/viewer/2022062312/5558a85ed8b42aa6708b530c/html5/thumbnails/45.jpg)
About me @anthonyalbertyn Front-end web developer Co-founder and organiser of
#drupalcambs http://www.meetup.com/drupalcambs