Contributions API

drush_tools_sync

Definition

drush_tools_sync($source, $destination)
contributions/drush/drush_tools/drush_tools.module, line 74

Description

Push files from or to the local Drupal install using SSH and RSync

Return value

void

Code

<?php
function drush_tools_sync($source, $destination) {
  // Local paths are relative to Drupal root
  if (!strstr($source, ':')) {
    $source = DRUSH_DRUPAL_ROOT. ":";
  }
  if (!strstr($destination, ':')) {
    $destination = DRUSH_DRUPAL_ROOT. "/$destination";
  }
  
  // Prompt for confirmation. This is destructive.
  if (!DRUSH_SIMULATE) {
    drush_print(t("You will destroy data from !target and replace with data from !source", array('!source' => $source, '!target' => $destination)));
    if (!drush_confirm(t('Do you really want to continue?'))) {
      drush_die('Aborting.');
    }
  }
  
  $options = '-az';
  $exec = "rsync -e ssh $options --exclude \"*.svn*\" $source $destination";
  if (DRUSH_VERBOSE) {
    // the drush_op() will be verbose about the command that gets executed.
    $options .= 'v';
  }

  return drush_op('system', $exec) !== FALSE;
}
?>