drush rsync @mysite.stage:%files sites/default/files
Results in
You will destroy data from /mysite/sites/default/files and replace with data from @mysite.stage:/mysite/%files
Which is obviously fails as @mysite.stage is not a valid host.

Flipping the command to
drush rsync sites/default/files @mysite.stage:%files
Works just fine.

Tried to debug a bit, but I'm not familiar with Drush internals and got lost. I think the problem is occurring in _drush_sitealias_get_record().

Comments

levelos’s picture

Am I the only one out there seeing this? Seems rather significant to not have the core rsync command working when using site aliases.

moshe weitzman’s picture

Status: Active » Postponed (maintainer needs more info)

The issue submission guidelines ask you to provide paste in the output of your command when run with --debug. That shows what drush is calling internally. In the case of rsync, you can alternatively run with --simulate and you see the bash without actually running it.

levelos’s picture

Status: Postponed (maintainer needs more info) » Active

Sure thing Moshe, here you go:

$ drush rsync --debug  --simulate @[alias group].prod:%files files
Bootstrap to phase 0. [0.02 sec, 2.08 MB]  [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.02 sec, 2.25 MB] [bootstrap]
Bootstrap to phase 0. [0.07 sec, 5.44 MB]  [bootstrap]
Found command: core-rsync (commandfile=core) [0.07 sec, 5.44 MB]  [bootstrap]
Initializing drush commandfile: drush_make [0.07 sec, 5.44 MB] [bootstrap]
Initializing drush commandfile: drush_make_d_o [0.07 sec, 5.44 MB] [bootstrap]
Initializing drush commandfile: user [0.07 sec, 5.44 MB] [bootstrap]
Including .../drush/commands/core/rsync.core.inc [0.07 sec, 5.44 MB] [bootstrap]
Load alias @[alias group].prod [0.07 sec, 5.51 MB] [notice]
Load alias @[alias group].prod [0.07 sec, 5.51 MB] [notice]
Load alias @self [0.07 sec, 5.51 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.08 sec, 5.51 MB] [bootstrap]
Initialized Drupal 6.22 root directory at /[path to local project]/drupal [0.09 sec, 6.17 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.09 sec, 6.17 MB] [bootstrap]
Initialized Drupal site default at sites/default [0.09 sec, 6.18 MB]  [notice]
Calling system(rsync -e 'ssh ' -azv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress @[alias group].prod:/[path to local project]/drupal/%files /[path to local project]/drupal/files);
Command dispatch complete [0.28 sec, 6.48 MB]  [notice]
Peak memory usage was 6.53 MB [0.28 sec, 6.48 MB]  [memory]
greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

Works for me on drush-5.x-dev. Try with today's master; if it does not work, then post your 'mysite' aliases file.

levelos’s picture

Getting the same output with the latest 5.x-dev. Must be something I'm missing in my aliases file. Snippet:

// @file: List of Drush aliases for this project.

$aliases['prod'] = array(
  'uri' => 'example.com',
  'root' => '[full remote root path]',
  'db-url' => 'mysql://user:password@server/database',
  'remote-host' => 'xxxxxx.gridserver.com',
  'remote-user' => '[remote user]',
  'path-aliases' => array(
    '%files' => 'files',
    '%dump-dir' => 'data/tmp',
  ),
  'source-command-specific' => array (
    'sql-sync' => array (
      'no-cache' => TRUE,
    ),
    'rsync' => array(
      'exclude-paths' => '.git:.DS_Store:*.komodoproject:.gitignore:.gitmodules:.komodotools:files',
    )
  ),
);
greg.1.anderson’s picture

Title: rsync fails if a remote alias is used as the source param » drush ignores %files in path-aliases, and rsync fails if a remote alias is used as the source param
Assigned: Unassigned » greg.1.anderson
Status: Postponed (maintainer needs more info) » Active

Did you update your drush on the remote side as well? Drush will contact the remote side to fill in path aliases that do not exist in the site alias record. One bug I did find when investigating #5 is that drush is ignoring %files inside path aliases. The only time I saw "@alias:%files" was when the backend invoke to the remote drush failed. Maybe a combo of these two bugs is getting you, although if that is the case, then I cannot explain why it would work when the alias is in the target position.

levelos’s picture

Thanks for the follow up Greg. The remote host in this case doesn't actually have Drush installed, it's an old legacy shared host. Do you need Drush on the remote host in order to run rsync?

Drush will contact the remote side to fill in path aliases that do not exist in the site alias record.

What paths need to be included in the alias to avoid engaging Drush on the remote host? Although if %files is ignored, then the problem will still exist ...

greg.1.anderson’s picture

Correct; you have your alias file set up correctly, but for some reason drush tries to contact the remote site to determine what the value of %files should be. Since you don't have drush there, you get hit by the bug in #6. Once that bug is fixed, you won't need drush on the remote side.

greg.1.anderson’s picture

Assigned: greg.1.anderson » msonnabaum
Status: Active » Patch (to be ported)

Fixed in master; commit http://drupalcode.org/project/drush.git/commit/8a29871

Could be back-ported to drush-4.x if desired.

msonnabaum’s picture

Status: Patch (to be ported) » Fixed

Backported.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.