Christian Schlensker
Christian Schlensker

Reputation: 22488

How do I get Drush rsync to use site-aliases correctly?

I'm using Drush 4.2 and I'm trying to rsync files from a the dev server to my local machine. My aliases.drushrc.php is located in the root of my local drupal installation and has the following in it:

 $aliases['local'] = array(
      'root' => '/Users/christian/Sites/site-root',
      'path-aliases' => array(
        '%files' => 'sites/default/files'
     ),

 ); 

$aliases['dev'] = array(
    'root' => '/var/www/vhosts/some-domain.com/subdomains/dev/httpdocs',
    'remote-host' => 'some-domain.com',
    'remote-user' => 'root',
    'path-aliases' => array(
      '%drush' => ' /var/tools/drush/drush',
      '%files' => 'sites/default/files',  
     ),
  );

As a test I try to run this from the local drupal root:

drush rsync @dev:%files ~/Desktop/test/

I expect @dev:%files to expand to the remote file path but instead I get:

You will destroy data from /Volumes/MacintoshHD/Users/christian/Desktop/test/ and replace with data from @dev:/Volumes/MacintoshHD/Users/christian/Sites/site-root/%files

Any ideas?

UPDATE: I've also found that when I'm try the command:

drush dd @dev:%files

I get

Target '@dev:%files' not found.

UPDATE 2

I've found that the issue seems to be coming from the location of the aliases.drushrc.php file. I had it in the drupal root of the site I was working on. I found that if I moved it to ~/.drush/ then everything worked perfectly.

I'd prefer to have it under source control though. I tried putting it in sites/default/ but it had the same problems as before. I'll award the bounty to whomever tells me where to put this file so it's under the source controlled site root.

Upvotes: 2

Views: 3071

Answers (1)

teknikqa
teknikqa

Reputation: 210

You can set the alias path in your drushrc.php config file.

If this is not set, then drush searches these locations (in this order) for the alias file.

  • /etc/drush
  • drush installation folder
  • $HOME/.drush
  • insides the sites folder of your drupal site

Check the readme for more details.

BTW: You have a comma missing in your declaration of 'local' alias. Modify it as:

'%files' => 'sites/default/files',

Upvotes: 2

Related Questions