1 min read

Syncing Environments Using Drush

Syncing Environments Using Drush

 

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.


Related Posts

2 min read

What Can Drush Do For You? Part 1 of 4

Drush is a command line interface tool used to help manage and maintain Drupal installations. Even novice Drupal developers soon realize how much of a benefit Drush can be. From creating aliases, to...
2 min read

How to use Drush to Maintain Modules

We've seen how Drush Site Aliases can save any Drupal developer time in multiple environments. Now, we'll discuss how Drush can also be used to maintain a site's readiness. Part of the way a Drupal...
2 min read

Using Drush to Check Site Status

We recently discussed how you can use Drush to maintain modules on your site. You can also use Drush to learn important configuration information, or discover errors that have been logged, without...
1 min read

10 Things We Love About Drupal

It's no secret that our team LOVES using Drupal to build unique solutions for our customers. There are so many reasons to love Drupal; just ask anyone at DrupalCon. Here are the top 10 reasons as to...