Drush Computer

Now that you have learned what a helpful tool Drush can be for all Drupal developers, let's think about how this, in combination with other command line tools, can make your jobs even easier. Any professional establishment will use version control and multiple environments, such as Sandbox (Development), Staging, and/or Production in order to maintain and modify code. In combination with Drush and some shell scripting, this can make for some very powerful tools.

When bringing a Drupal site from one environment to another there are generally three things to worry about:
  1. Code Base
  2. Database
  3. Media

Each part requires different tools to be used. The code base can be handled simply by using whatever version control is being utilized for the project. The database could be handled by mysql and the media using scp or rsync. If you have already set up aliases however, the last two steps can be handled rather easily using Drush.

  • drush sql-sync @production @dev
  • drush rsync @production:%files @dev:%files

If the alias files are set up correctly for each installation, these two commands will handle the last two parts. The above two commands will pull down the database on production and move it into the development environment. This saves a lot of time by not having to SSH into that environment's server and move the files manually.

Making sure aliases are set up correctly is a key part in the database sync. There are options available that will allow you to ignore some tables. This is useful in the case of the Cache tables as well as Watchdog. For larger databases it has the potential to save some time.

Once you have the hang of the different functionalities, get creative and think about what could be automated in your current processes. Some suggestions include:

  • Updating client's modules / Drupal core
  • Automatically generating aliases
  • Onboarding clients

The fact is, the possibilities are endless; and with a tool as versatile as Drush there is no limit to how it can help a Drupal developer with their work.

Colby Johnson
By Colby Johnson

A programmer through and through, Colby is a man commited to finding simple solutions to complex problems. Improving efficiency one mouse click at a time.

Leave Your Comment