5 Reasons You'll Love Using Drush With Drupal

Submitted by Rick Manelius on Fri, 03/30/2012 - 19:29

The command line: most programmers love its power; most web users fear its (alleged) complexities. But for those willing to dive in, the reward is great. Using Drush on Drupal can save you several hours a week just on website maintenance tasks alone. Here is a short list to get you started:

1. Download and Install Multiple Modules Simultaneously

Installing modules on drupal is easy. You just have to

Go to Drupal.org

Search for the module's page

Download the module's zip file

Unzip

Move to sites/all/modules

Open up your web browser

Go to the modules page

Click off the checkbox for the module

Save your changes

That's 9 steps per module. And if you have 30+ modules to install, that can take up to several hours if you're not nimble with your keyboard and mouse. With drush, you can do it in 2 lines:

The above commands may look ominous, but it's just drush 'command' and then a list of modules. Drush takes care of the rest.

2. Automatic Module Updates

Updating modules can be a pain. You have to check for avaialble updates, then repeat the process above in #1. Or, you can run: "drush up." This will tell drush to:

check which modules are installed on the current site

check to see if there are updates available

notify you what modules are out of date

ask you if you'd like to proceed

download all the modules and place them into the proper location

run update.php for you

This function alone saves me 2 hours a week.

3. Quickly Clear All Caching

You made a change to your site, but it's just not showing up! It might be a cache thing. Views, blocks, css, javascript: many components of Drupal are cached for performance. But this can make development difficult because you need to keep navigating to the admin areas to clear the system cache and flush the changes.

OR, you can run "drush cc all" to clear all the caching systems at the same time. This is super convenient.

4. Easy Backups

If you're developing on the bleeding edge (Drupal 7 with only dev versions of all of your modules, possibly with patches), you've probably experienced a corrupt database that simply could not be recovered. No fun. The easiest way to protect yourself is quick backups. But just like clearing your cache, you don't want to have to leave the page you're on and come back. Simply run "drush bam-backup" and a database copy will be generated and downloaded into the manual backups directory. For bleeding edge projects, I use this command compulsively because it's saved me so many times.

5. Control multiple sites

If you run more than one site (or a dozen sites), it can be tedious to manually update the modules at the same time. But drush allows you to create scripts and installation profiles, so you can quickly run the same commands on all of them. "drush @site1 up; drush @site2 up; drush @site3 up" would run the module update commands on 3 different sites, one right after another, without having to navigate your terminal to each site in between. This gives you a command center feel and allows you to connect to each site from one location, saving lots of time and focus for the bigger tasks at hand.

I hope you enjoyed this. If you have any questions or things to add, please leave a comment below. Are you using drush? If not, what's holding you back?