If I have aliases set up like so:

$aliases['local'] = array (
  'uri' => 'mysite.localhost',
  'root' => '/Users/me/Sites/mysite',
  'path-aliases' => array(
    '%dump' => '/tmp/mysite_sql_dump.sql',
   ),
);
$aliases['dev'] = array (
  'uri' => 'mysite.com',
  'root' => '/var/www/vhosts/mysite.com/httpdocs/',
  'remote-host' => 'mysite.com',
  'remote-user' => 'me',
  'path-aliases' => array(
    '%dump' => '/var/www/vhosts/mysite.com/private/mysite_sql_dump.sql',
   ),
);

Then I find that the sync only works the first time I run it. If I make db changes on @dev and then run sql-sync again, then the command appears to work with no errors or further messages (it says "You will destroy data...", I answer "y" as usual), but the local database is unchanged.

In order to get the database imported I either have to manually delete the local dump file first, or omit %dump from my local alias setting. The latter works fine as far as I can tell, but then I see the warning about "Using temporary files to store and transfer sql-dump..." I can happily ignore the warning but it still seems like there is a bug here.

Comments

greg.1.anderson’s picture

I'm guessing that it's working as designed, but perhaps the warning messages are not accurate. Check out drush help sql-sync, and pay close attention to the cache options, which stipulate that the dump file should be used as-is unless it is older than the cache period. You can turn this off if you don't want the behavior (e.g. if you're only using the dump file as a sort of backup).

markabur’s picture

Title: sql-sync fails if %dump is set and local file already exists » sql-sync unnecessarily warns about destroying data

Ok, thanks, yeah if the command isn't actually going to destroy any data then it shouldn't need to put up the warning. :-)

I was just speccing the %dump file because of that warning about rsync performing better if I do that... the fact that the dump file sticks around is a side effect I didn't really care for anyway, once I noticed it.

greg.1.anderson’s picture

Title: sql-sync unnecessarily warns about destroying data » sql-sync warning message is deceptive when cache is being used
Assigned: Unassigned » greg.1.anderson

Yeah, the cache is also good for rsync performance, especially if you insure that your db dump is done in a stable order (drush default for mysql, I think? I use postgres...)

I'll look into fixing the message when the cache is in effect. Note that you might still destroy data if you sync from a cache file, though (e.g. if you changed the target since the last sync...)

greg.1.anderson’s picture

Version: All-versions-3.3 »

Oh, but I'm going to fix it in HEAD...

markabur’s picture

Cool. Actually the cache message that comes up when running -v is good, would it make sense to make that show up even without -v? Seems like if the "destroy-data" message is going to show without -v then the "using-cache-instead" message should as well.

greg.1.anderson’s picture

That makes sense to me.

greg.1.anderson’s picture

Version: » 8.x-6.x-dev
Component: Code » Base system (internal API)
Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

markabur’s picture

I don't use GitHub or StackExchange, so I will just leave it closed. I don't really care about the bug anymore anyway.