3

I've just discovered the wonderful world of drush aliases, and I'd like to use drush to keep a dev site in sync with the live site (and visa versa). So far I've figured out that the following command does it pretty well for a site in the sites/ folder:

drush rsync @mysite.com.live @mysite.com.dev

I'd like to be able to sync modules and core the same way. Is there a way to do that with drush?

4

To sync contrib:

drush rsync @mysite.com.live:%modules @mysite.com.dev:%modules

%modules will be rewritten to sites/all/modules.

Drush does not have a path alias for the core modules folder, but you could do this:

[REDACTED]

The answer I gave before only sync'ed the core modules folder; what you really want is all of core, minus any sites or contrib modules. To do that, use the following rsync command:

drush rsync @mysite.com.live @mysite.com.dev --exclude="sites/*"

To sync core and contrib together:

drush rsync @mysite.com.live @mysite.com.dev --include="sites/all" --exclude="sites/*"

Add '-s' prior to the rsync to run in simulated mode (i.e. drush -s rsync ...); if you do this, Drush will print out the rsync command that it would run for those parameters without actually executing it.

Update:

Yes, the rsync command shown in the question will sync the entire Drupal root. If you want to sync only the sites folder for one particular Drupal site, you could try this:

drush rsync @mysite.com.live:%site @mysite.com.dev:%site

At this point, you might be tempted to chain together all of the commands shown above, and drop it into a script to sync everything that one site needs to run. If that's your intention, you might want to try the following variant, which rsync's everything except the other multisites:

drush --exclude-other-sites rsync @mysite.com.live @mysite.com.dev

Again, run with -s to see what it's going to do with that command.

  • Running drush -s rsync @mysite.com.live @mysite.com.dev gave me: Calling system(rsync -e 'ssh -i /home/me/.ssh/id_rsa' -akz --exclude="a bunch of VCS files" --exclude="settings.php" starkart@mysite.com:/path-to-drupal/drupal// /path-to-drupal/drupal/); This makes it look like it's syncing the entire drupal installation. That's not what I want, and I didn't think you could set up an alias like that anyway. What's up with that? – JoBu1324 May 22 '13 at 16:37
  • Ok, the new output makes sense. The bottom line, then, is that running rsync on an alias syncs the entire drupal installation by default. That blindsided me - I thought the purpose of the alias file was to cause drush to act on a particular site only. Thanks for your help! – JoBu1324 May 22 '13 at 18:12
  • 1
    We could make --exclude-other-sites the default; that would have to be discussed in the Drush issue queue. You could set $command_specific['rsync']['exclude-other-sites'] = TRUE; in your drushrc.php file, if you preferred. – greg_1_anderson May 22 '13 at 18:20
  • Thanks for the setting, I'll implement that in my alias files so it works as expected. – JoBu1324 May 22 '13 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.