David Lohmeyer's Blog

Easily pull down a production Drupal site with drush sql-sync and drush rsync

Both of these drush commands are awesome on their own, but they really need a wrapper script to become workhorses. I built this script to refresh a local Drupal environment with 1 command. You can choose file folder sync, databases, or both. This assumes you have working Drupal installations on both ends already (minus the database). So once you're setup with your settings files and Drupal codebase, you'd run this to populate the site. Click here for the Github repository. Summary:

  • This utilizes drush sql-sync and drush rsync to pull down a production server's file system and database to your local version by executing the shell script.
  • You must have a drush aliases file set up with local and prod aliases for this to work. Sample included at the end of the shell script.
  • Fill out the top variables of the shell script and then run it. It assumes your local environment can log in to the remote environment via SSH already.
  • The script will create a local database for you if it doesn't exist yet.

Related Posts