Drush and cloning

I need to pull down a site I have on my other computer but haven't setup here for local development. I keep thinking there should be a 'drush clone' command... well there is but it clones modules not the way I'm thinking of. Basically the command I have in mind would:

  1. Clone the git repository of the site into the proper local directory.
  2. Copy the files from the production or developer site.
  3. Create the local database and sync from production or developer instance.
  4. Or instead of syncing the database do a site install if that's called for.

This requires of course that drush aliases already exist for the site. How to handle this and keep everybody in sync. Well, here's my stab at a highly configurable, very customizable drush configuration for people who work with one or more teams.

<?php

/**
*
* This is a sample drushrc.php file designed to go in a user's .drush directory.
* It does not load anything specifically but enables loading of team configurations
* and an individual user's configurations.
*/

define('DOCROOT_STORAGE', '/Users/someuser/Sites/');
define('TEAM1_DRUSH_CONFIG', DOCROOT_STORAGE . 'team_directory/drush');
// This line is optional supply a value if you want to add it.
define('USER_DRUSH_CONFIG', '/Users/someuser/Configurations/drush');

foreach (array(TEAM1_DRUSH_CONFIG, USER_DRUSH_CONFIG) as $directory) {
  if (!empty($directory)) {
    $options['config'][] = $directory . '/drushrc.php';
    $options['include'][] = $directory . '/commands';
    $options['alias-path'][] = $directory . '/aliases';
  }
}

This bit makes it possible both for my individual drush configurations to be kept in a repository but also for the various team(s) I'm working with to do the same. Next up is adding some variables to the individual site configurations to store the upstream git repos and my forks. With this information it would be simple enough to clone the git repository into DOCROOT_STORAGE and do most of the site setup right there.

Category: