2

I want to use the drush rsync command to transfer files from a remote server to the local Drush, using the Drush dump-directory on both servers. In my mind it would look something like this:

$ drush rsync @remote$dump-dir/drup.sql.gz $dump-dir/drup.sql.gz

Because of limitations at my host I can't drush dump remote mysql directly. Instead I'll be dumping locally on the remote server, then using drush rsync to transfer the dumps to a safe (non-web accessible) directory.

I could use regular rsync but I am trying to make a bash script for a variety of host directory trees. The drush dump-directory seems ideal for this, because:

  • every drush site has one,
  • it's already outside of the public web directory (/web, /www, etc),
  • advanced users can reconfigure the dump-dir in .drushrc as needed.

I understand that Drush uses dump-dir for MySQL dumps. Is it also possible to command Drush to rsync files to that same directory?

The dump directory can be configured in drushrc like so:

$options['dump-dir'] = '/path/to/dumpdir';

How does this get reverse-engineered for command line?

4

1 回答 1

1

You can access your directory variables via path-aliases, for example:

$aliases['remote'] = array(
  'site' => 'mysite',
  'path-aliases' => array(
     '%dump-dir' => '/path/to/dumps', // Can be webroot relative path also.
     '%files'   => 'sites/default/files',
     '%private' => 'sites/default/private/files',
     '%custom' => '/my/custom/path',
  ),
);

Then run:

drush rsync @remote:%dump-dir/drup.sql.gz %dump-dir/drup.sql.gz

You may test them before via: drush dd %%dump-dir

See: example.aliases.drushrc.php

于 2015-04-04T14:27:50.527 回答