Syncing Environments Using Drush

by | Jun 9, 2015 | Development

Share this post

 

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.

Insights

Helping B2B leaders use technology to drive business

2026 B2B Content Marketing Trends

2026 B2B Content Marketing Trends

What Mid-Market Leaders Need to Do Right Now Over the past year, my team and I have been doing something that’s become surprisingly rare in digital business: meeting face-to-face with our clients. Whether it's healthcare technology, B2B manufacturing, nonprofits, or...

The Cost of Not Doing Anything

The Cost of Not Doing Anything

Why B2B and Nonprofits Should Invest in Their Websites and Portals In today’s digital first world, a website or customer portal isn’t just a “nice to have” ,  it’s the foundation of your organization’s success. Yet, many B2B companies and nonprofits fall into the trap...

A Guide To The Difference Between GEO, AIO and SEO

A Guide To The Difference Between GEO, AIO and SEO

For years, we built websites to earn authority with search engines.  Recent research outlines how AI summaries replacing traditional search results and are having a tremendous negative effect on website traffic.  Since SEO is no longer driving customers to your site,...