I'd like to use drush to sync files from local server to production server. I have edited the aliases.drushrc.php file and placed inside /drush/aliases in both local and remote machines. Everything seems to work fine except that drush understands that both sites are in the same server since I do not know how to tell drush that local is in another machine in my local server. I guess it's something to do with uri but I do not know what should I write there.

I've tried with this:

$aliases['local'] = array(
  'uri'  => 'mysite.localhost',    
  'root' => '/home/user/www/mysite',

and this:

$aliases['local'] = array(
  'uri'  => 'localhost/mysite',    
  'root' => '/home/user/www/mysite',

being mysite the name of the folder placed in /home/user/www in my local server, but none of them seem to work.

Anyone can tell me what am I doing wrong?


I have placed mysite.aliases.drushrc.php in my local sites folder. However I didn't succeed with the following code in my local site:

drush rsync @mysite.live:%files @mysite.local:%files

This is what I get:

You will destroy data from @mysite.local:/home/user/www/mysite/%files and replace with data from @carloscamara.live:/home/user/www/mysite/%files
Do you really want to continue? (y/n): y
The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at main.c(1166) [Receiver=3.0.8]

This is mysite.aliases.drushrc.php content:

$aliases['local'] = array(
    'uri'  => 'localhost/mysite',    
    'root' => '/home/user/www/mysite',
    'path-aliases' => array(
      '%files' => 'sites/default/files',
     'command-specific' => array (
       'sql-sync' => array (
         'no-cache' => TRUE,

$aliases['live'] = array(
    'uri' => 'mysite.com',
    'root' => '/home/user/mysite';
    'remote-machine' => 'mysite.com';
    'remote-user' => 'myusername',
    'remote-host' => 'mysite.com',
    'path-aliases' => array(
      '%files' => '/home/myusername/mysite.com/sites/default/files',
  • 1
    It does not look like your parenthesis balance above; was that a transcription error, or is it wrong in your aliases file too? Try drush sa @mysite to test; it should print out the records for @mysite.local and @mysite.live. Once this is working, try drush -s rsync @mysite.live @mysite.local, and if that prints reasonable stuff, then try drush -s rsync @mysite.live:%files @mysite.local:%files. Also, try pulling down today's master of drush with git clone --branch master http://git.drupal.org/project/drush.git, as I recently committed bug fixes for %files and rsync. – greg_1_anderson Feb 18 '12 at 20:44

To set up to do a drush rsync or drush sql-sync to a remote machine, set up aliases for both sites on the local machine. The alias for the local site should be as you have shown in your question. For the remote machine:

$aliases['stage'] = array(
    'uri'  => 'staging.mysite.com',    
    'root' => '/home/user/www/mysite',
    'remote-host' => 'stagingfqdn.myisp.com',
    'remote-user' => 'wwwadmin',

'remote-machine' should be the fully qualified domain name of the machine that hosts the remote site. This may or may not be the same as the 'uri' parameter. You might need to edit /etc/hosts, but only if the remote machine is not resolvable in DNS (unusual). The 'remote-user' should be the name of the user that owns the files at the Drupal root; usually this is not the user that the web server runs as.

It sometimes makes sense to sql-sync from local to remote -- for example, when bringing a site live for the first time. Usually, though, you are going to want to rsync your code from local to remote (or check it out from a vcs), and sql-sync your database from remote to local (and never the reverse). This will insure that you do not overwrite user-generated content. See the features module for one common solution for pushing configuration to the remote machine via copying files.

Edit: Made a typo: said 'remote-machine', but it should have been 'remote-host'. Corrected above.

Edit 2: Originally I said "rsync your files from local to remote (and never the reverse), but I meant code. Corrected above. It is, of course, reasonable and customary to rsync %files from remote to local, as shown in your updated question.

| improve this answer | |
  • Thank you very much for your reply. I placed mysite.aliases.drushrc.php in my local sites folder and made some changes to it (see question again -I edited to provide more details). However I didn't succeed. – ccamara Feb 18 '12 at 18:11

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.