Drush and specifying source dump and target dump options
Using temporary files to store and transfer sql-dump. It is recommended that you specify --source-dump and --target-dump options on the command line, or set '%dump' or '%dump-dir' in the path-aliases section of your site alias records. This facilitates fast file transfer via rsync.
What exactly does that mean? Is some random location i make up really better than the temporary directory? Or should i be giving it some specific directory, on different serves or something? Guidance please.
Failure
in drushrc.php
<?php
$options['dump-dir'] = '/home/ben/tmp/dumps';
?>
with no matter what i did to the folder:
ben@ubuntu:~/code/sdl/web (continuum *)$ sudo chown root:root -R /home/ben/tmp
ben@ubuntu:~/code/sdl/web (continuum *)$ sudo chmod 775 -R /home/ben/tmpben@ubuntu:~/code/sdl/web (continuum *)$ ls -la /home/ben/tmp/dumpstotal 8
drwxrwxr-x 2 root root 4096 2011-08-28 22:12 .
drwxrwxr-x 3 root root 4096 2011-08-28 22:12 ..
fails.
drush sql-sync --alias-path=.. @sdl.stage @sdl.local
You might want to make a backup first, using the sql-dump command.
Do you really want to continue? (y/n): y
mysqldump: Can't create/write to file '/home/ben/tmp/dumps/simone.mayfirst.org_drupal-sdl-stage.sql-1314585287' (Errcode: 2)
mv: cannot stat `/home/ben/tmp/dumps/simone.mayfirst.org_drupal-sdl-stage.sql-1314585287': No such file or directory
rsync: change_dir "/home/ben/tmp/dumps" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1526) [Receiver=3.0.7]
Could not rsync from [error]
simone.mayfirst.org:/home/ben/tmp/dumps/simone.mayfirst.org_drupal-sdl-stage.sql
to /home/ben/tmp/dumps/sdl.sql
But this works:
<?php
$options['dump-dir'] = '/tmp';
?>
ben@ubuntu:~/code/sdl/web (continuum *)$ ls -la /tmp/
Go figure.
Comments
put location-specific %dump-dir in aliases.drushrc.php
I agree this is a pretty big wtf, but it kinda make sense: specifying dump-dir in drushrc.php means the same folder must exist on all environments.
To get around this, add location-specific '%dump-dir' to your specific alias locations inside your aliases.drushrc.php file where you define @sdl.stage and @sdl.local.
This will allow you to have one dump location on your local environment, and another on your staging server.
I actually use the %dump option, to specify the exact file i want to use, instead of %dump-dir...
<?php
// @file ~/.drush/example.aliases.drushrc.php
// Development environment.
$aliases['local'] = array('uri' => 'example.local',
'root' => '~/Sites/example/www',
'db-url' => 'mysql://example:example@localhost/example',
'path-aliases' => array(
// Path for sql-sync dumps.
'%dump' => '~/Sites/example/assets/db_snapshot/development-' . date('Ymdhis') . '.sql',
),
); // Staging environment.
$aliases['stage'] = array(
'uri' => 'staging.example.com',
'root' => '/home/example/public_html/www',
'db-url' => 'mysql://example:example@localhost/example',
'remote-host' => 'staging.example.com',
'remote-user' => 'example',
'path-aliases' => array(
// Path for sql-sync dumps.
'%dump' => '/home/example/public_html/assets/db_snapshot/staging-' . date('Ymdhis') . '.sql',
),
);
?>
Post new comment