Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Intro to Drush

8,054 views

Published on

An introduction to the the who, what, why when and how of Drush, the command line utility for Drupal. Presentation given at the Sacramento Drupal Users Group meeting on 6/15/2011

Published in: Technology

Intro to Drush

  1. 1. Intro to Drush• Who is it for?• What is it?• Why should you use it?• When should you use it?• How do you use it?
  2. 2. What is Drush?
  3. 3. What is Drush?A command line interface for managing your Drupal website.
  4. 4. What is Drush?A command line interface for managing your Drupal website. $ drush cc
  5. 5. Do I really need it?
  6. 6. Do I really need it?• No. But you REALLY want it!
  7. 7. Do I really need it?• No. But you REALLY want it!• Useful during development process
  8. 8. Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites
  9. 9. Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites• +1 Drupal Street Cred...
  10. 10. Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites• +1 Drupal Street Cred...• (you look like a real smartypants)
  11. 11. What Can Drush Do For Me?
  12. 12. What Can Drush Do For Me?• Work with Drupal Core
  13. 13. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)
  14. 14. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules
  15. 15. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules• Work with Database
  16. 16. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules• Work with Database• Work with Users
  17. 17. •Work with Drupal Core Clear Cache $ drush cc
  18. 18. •Work with Drupal Core Run Cron $ drush cron
  19. 19. •Work with Drupal Core Run update.php $ drush updb
  20. 20. •Work with Drupal Core Empty watchdog (log) table $ drush wd-del
  21. 21. •Work with Drupal Core Empty watchdog (log) table $ drush wd-del $ drush wd-del --type=cron
  22. 22. •Work with Drupal Core Index content for search $ drush search-index $ drush search-reindex
  23. 23. •Work with Drupal Core update core minor (7.1→7.2) $ drush up
  24. 24. •Work with Drupal Core update core minor (7.1→7.2) $ drush up update core major (6.x→7.x) $ drush sup
  25. 25. •Work with Drupal Core run tests $ drush test-run --all
  26. 26. •Work with Drupal Core Install Drupal (D7)
  27. 27. •Work with Drupal Core Install Drupal (D7)$ drush si --db-url=mysql://root:pass@localhost/port/dbname --account-pass=abc123 --account-mail=admin@example.com --site-name=My Site
  28. 28. •Work with Drupal Core Status & Being Nosy $ drush st $ drush search-status $ drush vget
  29. 29. •Work with Fields (D7) Clone, Create, Delete, Get Info $ drush field-create article $ drush field-clone tags labels $ drush field-delete article $ drush field-info article
  30. 30. •Work with Modules Download $ drush dl cck views token
  31. 31. •Work with Modules enable / disable$ drush en content text views views_ui$ drush dis content text views views_ui
  32. 32. •Work with Modules update $ drush up
  33. 33. •Work with Modules update $ drush up = $ drush upc + $ drush updb
  34. 34. •Work with Modules status (enabled/disabled/ver.) $ drush pm-list
  35. 35. •Work with your Database TIP: make sure mysql command exists $ mysql -uroot -p
  36. 36. •Work with your Database execute queries $ drush sql-query “SELECT * FROM {users} WHERE uid=1”
  37. 37. •Work with your Database export DB as SQL (mysqldump) $ drush sql-dump --result-file=../06_15_2012.sql
  38. 38. •Work with your Database drop (YIKES! BE CAREFUL!) $ drush sql-drop
  39. 39. •Work with your Database sync (rsync copy and import) $ drush sql-sync @prod @stage
  40. 40. •Work with your Users Create Users$ drush ucrt dustyb --mail=”dusty@sacdrupal.com” --password=”abc123”
  41. 41. •Work with your Users Cancel Users (anonymizes content) $ drush ucan dustyb
  42. 42. •Work with your Users Block Users $ drush ublk dustyb Unblock Users $ drush uublk dustyb
  43. 43. •Work with your Users Add Role to User $ drush urol “admin” dustyb Remove Role from User $ drush urrol “admin” dustyb
  44. 44. •Work with your Users Reset User’s Password$ drush upwd dustyb --password=”t&ur@tles”
  45. 45. •Work with your Users Get User Info $ drush uinf dustyb
  46. 46. What Drush Doesn’t Do
  47. 47. What Drush Doesn’t Do Anything with your content!
  48. 48. Do Even More...
  49. 49. Do Even More...• Devel Module• Backup and Migrate• Views Bulk Operations• XML Sitemap• Node Export• Apache Solr Search Integration• Module Builder• Coder• Features, Views and CTools• Many more....
  50. 50. Do Even More...
  51. 51. Drush Aliases aliases.drushrc.php
  52. 52. Drush Aliases aliases.drushrc.php$aliases[example_stage] = array( uri => staging.example.com, root => /var/www/stage_example, db-url => mysqli://root:pass@localhost/example_stage,);$aliases[example_prod] = array( uri => www.example.com, root => /var/www/example, db-url => mysqli://root:pass@localhost/example_prod, remote-host => 192.232.232.33’, remote-user => carsonbl’,);
  53. 53. Drush Aliases aliases.drushrc.php$aliases[example_stage] = array( uri => staging.example.com, root => /var/www/stage_example, db-url => mysqli://root:pass@localhost/example_stage,);$aliases[example_prod] = array( uri => www.example.com, root => /var/www/example, db-url => mysqli://root:pass@localhost/example_prod, remote-host => 192.232.232.33’, remote-user => carsonbl’,); $ drush @example_stage en token
  54. 54. Drush Aliases aliases.drushrc.php$aliases[example_stage] = array( uri => staging.example.com, root => /var/www/stage_example, db-url => mysqli://root:pass@localhost/example_stage,);$aliases[example_prod] = array( uri => www.example.com, root => /var/www/example, db-url => mysqli://root:pass@localhost/example_prod, remote-host => 192.232.232.33’, remote-user => carsonbl’,); $ drush @example_stage en token $ drush sql-sync @example_prod @example_stage
  55. 55. Drush Make
  56. 56. Drush Make$ drush make example.makeexample
  57. 57. Drush Make $ drush make example.make example• Extension to Drush
  58. 58. Drush Make $ drush make example.make example• Extension to Drush• Prepares your site for installation
  59. 59. Drush Make $ drush make example.make example• Extension to Drush• Prepares your site for installation• Create complicated Drupal distribution using a single text file
  60. 60. Drush Make $ drush make example.make example• Extension to Drush• Prepares your site for installation• Create complicated Drupal distribution using a single text file• Automates download of core, modules, patches, external libraries and external code from repos
  61. 61. Installation Profiles
  62. 62. Installation Profiles $ drush si example
  63. 63. Installation Profiles $ drush si example• Works and set up like a module
  64. 64. Installation Profiles $ drush si example• Works and set up like a module• Allows you to script custom installation process
  65. 65. Drush Installation• Download http://drupal.org/project/ drush• Follow Installation Instructions in README.txt
  66. 66. Sorry Windows Users...
  67. 67. Sorry Windows Users... No Drush for you!!!
  68. 68. Other Install Options• Drupal Quickstart Project • drupal.org/project/quickstart • Pre-packaged PHP/LAMP development environment (Ubuntu) • Drush is pre-installed and ready to go!
  69. 69. Other Install Options• Cygwin (http://www.cygwin.com/) • Makes Windows kind of act like Linux • will have to set up a complete development environment
  70. 70. Other Install Options• WebEnabled (webenabled.com) • web-based development environment • Drush pre-installed • Also have simplistic web app in control panel to do drush visually • Free development environments!
  71. 71. Other Install Options• Acquia Dev Cloud (acquia.com) • web-based development environment • Drush pre-installed • full dev-stage-prod hosting environment • $149 /mo.
  72. 72. Other Install Options• Pantheon (getpantheon.com) • web-based development environment • Drush pre-installed • full dev-stage-prod hosting environment • aliases for each environment configured
  73. 73. Other Install Options• Your Hosting • Must have shell access! • You will have to install
  74. 74. Other Install Options• Get a Mac! ;-)• Dual-boot Linux• Install Linux
  75. 75. Resources• http://drush.ws - full documentation• http://drupal.org/project/drush• http://nuvole.org/blog/drush - check out the shortcuts• http://drupal.org/project/drush_make
  76. 76. Thank Youcarsonblack.com

×