I've searched and searched, and wrapped my head around site aliases, but I keep hitting a wall.

When I run:

drush sql-sync @dev @live

I get the following output:

Load alias @live					[notice]
Load alias @dev						[notice]
Load alias @live					[notice]
Load alias @dev						[notice]
Load alias @live					[notice]
Error: no database record could be found for @dev	[error]
Command dispatch complete          

Attached is my aliases.drushrc.php

Both of the following commands return the status of both fully working Drupal 6 installs:

drush @live status
drush @dev status

So then can anyone suggest what might be wrong? Why am I getting this error when I try to sql-sync:

Error: no database record could be found for @dev

Thanks for any help!

CommentFileSizeAuthor
aliases.drushrc.php_.txt1.06 KBwOOge

Comments

greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

Please try with 5.x-HEAD and see if it works for you there; I reproduced your setup on master, and had no troubles.

If you get the same result, also try:

drush @live sql-conf --all
drush @dev sql-conf --all
drush sa @live --show-passwords --with-db
drush sa @dev --show-passwords --with-db

The --show-passwords is optional, of course.

When you define your database record inside your site alias, then drush will use the record you provided, and will not attempt to look up the db record on the remote (or local) site. Therefore, you should never get the "no database record could be found for..." error when you have your db record defined in your alias.

That's the theory, anyway. It would be interesting to know why that code path is being run on your system. Do you have any other aliases.drushrc.php files anywhere on your system? Anything that might define another copy of @live or @dev? Try drush sa to see a list of all of the aliases drush knows about.

wOOge’s picture

Thanks for the help, but still no dice — I installed the latest 5.x-dev and commented out the database records in my site alias. I searched my dev box for any other aliases.drushrc.php, but found no other. I then ran the following commands on the dev box:

drush sa

@self
@dev
@live
default

Ran each of the following commands separately and they each came back with:

drush @dev sql-conf --all
drush @live sql-conf --all


Array
(
    [default] => Array
        (
            [default] => Array
                (
                    [driver] => mysql
                    [username] => dbuser
                    [port] => 
                    [host] => localhost
                    [database] => websitedb
                )

        )

)

Ran each of the following commands separately and they each came back nearly identical output (save for the different live and dev environments):

drush sa @dev --with-db
drush sa @live --with-db


$aliases['dev'] = array (
  'root' => '/var/www/website.com',
  'uri' => 'website.local',
  'path-aliases' => 
  array (
    '%dump' => '/Users/username/drupal_dump/dump.sql',
    '%files' => '/var/www/website.com/sites/default/files',
  ),
  'databases' => 
  array (
    'default' => 
    array (
      'default' => 
      array (
        'driver' => 'mysql',
        'username' => 'dbuser',
        'port' => '',
        'host' => 'localhost',
        'database' => 'websitedb',
      ),
    ),
  ),
);

All with the same result:

drush sql-sync @dev @live
Error: no database record could be found for @dev	[error]

drush sql-sync @live @dev
Error: no database record could be found for @live	[error]

Does the sql-dump directory and file have to have special permissions? Could that be the issue?
I'm using D7 and XAMPP on Mac OS X for @dev and an Ubuntu LAMP for @live.

Thanks again for your help with this!!

wOOge’s picture

Status: Postponed (maintainer needs more info) » Active
greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

Drush does the equivalent of drush @dev sql-conf --all to find the database record for your site, unless the database record is already present in the alias, in which case you should never get the error you're seeing.

Could you post the output from your sql-sync command with the --debug flag included?

wOOge’s picture

Hmm... strange. Ok here is the output for drush sql-sync --debug @dev @live

Bootstrap to phase 0. [0.02 sec, 1.52 MB]					[bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.02 sec, 1.64 MB]		[bootstrap]
Bootstrap to phase 0. [0.05 sec, 3.33 MB]					[bootstrap]
Found command: sql-sync (commandfile=sql) [0.05 sec, 3.33 MB]			[bootstrap]
Initializing drush commandfile: user [0.05 sec, 3.33 MB]			[bootstrap]
Including /Users/username/drush/commands/sql/sync.sql.inc [0.05 sec, 3.33 MB]	[bootstrap]
Calling drush command init function: drush_sql_sync_init [0.06 sec, 3.45 MB]	[bootstrap]
Load alias @live [0.06 sec, 3.45 MB]						[notice]
Load alias @dev [0.06 sec, 3.45 MB]						[notice]
Load alias @live [0.06 sec, 3.45 MB]						[notice]
Load alias @dev [0.06 sec, 3.46 MB]						[notice]
Load alias @live [0.06 sec, 3.46 MB]						[notice]
Error: no database record could be found for @dev [0.06 sec, 3.46 MB]		[error]
Command dispatch complete [0.06 sec, 3.45 MB]					[notice]
Peak memory usage was 3.55 MB [0.06 sec, 3.45 MB]				[memory]

You can see that @dev and @live get read twice for some reason... could that be a symptom?

greg.1.anderson’s picture

Version: 7.x-4.4 »

Not enough info in the debug output; too bad. You'll have to dig deeper; unfortunately, this is working on my machine, so it's hard to say what the failure point is.

wOOge’s picture

Correction I'm using D6 in this instance — too many sites on the go ;)

wOOge’s picture

Ok I did some digging. It seems that $source_db_url and target_db_url inside sync.sql.inc, starting at line 144 are not getting any values passed to them from reading the aliases file.

If I hard code the values:

$source_db_url = "mysql://dbuser:password@localhost/websitedb";

$target_db_url = "mysql://dbuser:password@localhost/websitedb";

It seems to work and I get the "You will destroy data from 1/1 and replace with data from 1/1" etc…

However there is a warning about using "temporary files to store and transfer sql-dump" — which is strange because I've defined these inside my aliases file as well — so something else is not getting passed.

After hitting "Y" to try the sync, I get the following:

ssh: Could not resolve hostname 1: nodename nor servname provided, or not known
ssh: Could not resolve hostname 1: nodename nor servname provided, or not known
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-40/rsync/io.c(452) [receiver=2.6.9]
ssh: Could not resolve hostname 1: nodename nor servname provided, or not known
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-40/rsync/io.c(452) [sender=2.6.9]
ssh: Could not resolve hostname 1: nodename nor servname provided, or not known

Now that all said, if I do a drush status @live it's able to connect to live and give me the full status back, so it's not a connection issue. It seems variables are not getting passed to the sync function, that are getting passed to other functions.

My limited knowledge of drush is limiting my ability to diagnose any farther.

Any of this help? — using drush to sync sites would save so much time over the db dumps and gzip uploads every week.

I really appreciate your time and help!!

greg.1.anderson’s picture

Shouldn't matter which version of Drupal you use here; I'm still on d6 for most of my sites too.

greg.1.anderson’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)
Sree12’s picture

Hi,

I am having the exactly same issue wOOge is having .Can anyone please guide if you have solved the same.Its very urgently needed.

Thanks

greg.1.anderson’s picture

This is a dup of a fixed issue, so try with the latest version of Drush. Asking questions in closed issues is inadvisable, because it takes a bit of luck for anyone to see your question.

artis’s picture

Version: » 7.x-5.8

In case anyone is looking here for any answer. I got this error message on a non-root shell user because I didn't sudo.