When I try to do a development to live sql-sync I get this error "Error: no database record could be found for" Can any one put some light on as to way?
Here is the output:
Gareth-MacBook:~ garethhall$ drush sql-sync @dev.tetoki @tetkoki --source-dump sqldump.sql -v -d
Bootstrap to phase 0. [0.04 sec, 1.3 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.04 sec, 1.43 MB] [bootstrap]
Bootstrap to phase 0. [0.12 sec, 3.51 MB] [bootstrap]
Found command: sql-sync (commandfile=sql) [0.12 sec, 3.51 MB] [bootstrap]
Initializing drush commandfile: drush_make [0.12 sec, 3.51 MB] [bootstrap]
Initializing drush commandfile: drush_make_d_o [0.12 sec, 3.51 MB] [bootstrap]
Initializing drush commandfile: user [0.12 sec, 3.51 MB] [bootstrap]
Including /usr/local/lib/drush/commands/sql/sync.sql.inc [0.12 sec, 3.52 MB] [bootstrap]
Calling drush command init function: drush_sql_sync_init [0.13 sec, 3.65 MB] [bootstrap]
Load alias @tetkoki [0.13 sec, 3.66 MB] [notice]
Load alias @dev.tetoki [0.13 sec, 3.66 MB] [notice]
Load alias @tetkoki [0.13 sec, 3.66 MB] [notice]
Running: /usr/local/lib/drush/drush.php --all --root='/Users/garethhall/Sites/tetokiretreat.co.nz/public_html' [command]
--uri='dev.tetokiretreat.co.nz' sql-conf --backend [0.14 sec, 3.66 MB]
Load alias @tetkoki [0.43 sec, 3.68 MB] [notice]
Error: no database record could be found for @tetkoki [0.43 sec, 3.68 MB] [error]
Command dispatch complete [0.43 sec, 3.65 MB] [notice]
Peak memory usage was 3.73 MB [0.44 sec, 3.65 MB]
This is the status
Gareth-MacBook:~ garethhall$ drush @tetoki status
Drupal version : 7.0
Site URI : stage.tetokiretreat.co.nz
Database driver : mysql
Database hostname : localhost
Database username : *********
Database name : ********
Database : Connected
Drupal bootstrap : Successful
Drupal user : Anonymous
Default theme : tetoki
Administration theme : seven
PHP configuration : /usr/local/lib/php.ini
Drush version : 4.2
Drush configuration :
Drush alias files :
Drupal root : /home/tetokiretr/public_html/stage
Site path : sites/default
File directory path : sites/default/files
I am able to do a live to development sql-sync with out a problem but why do I have to include the extra options?
This works
drush sql-sync @tetoki @dev.tetoki --source-dump sqldump.sql
This does not
drush sql-sync @tetoki @dev.tetoki
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | aliases.drushrc.php_.txt | 669 bytes | wOOge |
Comments
Comment #1
greg.1.anderson commentedIt seems that drush is having trouble making callbacks to itself, or perhaps the dev site just isn't set up correctly. If you are trying to set up the site for the first time, call with --create-db to set up the database. Make sure that the first time you call
drush rsync, you use the flag --include-conf to copy settings.php over. Then customize settings.php so that your dev site will use a different database than the live site (not necessary if they are on different machines, of course).Once you've done that, try:
drush @dev.tetoki statusand
drush @dev.tetoki sql-conf --allIf the later works, sql-sync should work too.
Comment #2
garethhallnz commentedHi Thanks for the help so far. Obviously the development @dev.tetoki is up and running perfectly, the @tetoki is also running but I used other methods to publish it. I thought it best I list how things are setup.
My aliases.drushrc.php
Doing drush command: drush @dev.tetoki status
Doing drush command: drush @dev.tetoki sql-conf --all
Doing drush command: drush @tetoki status
Doing drush command: drush @tetoki sql-conf --all
Doing drush command: drush sql-sync @dev.tetoki @tetoki
Hopefully you can see whats wrong.
Comment #3
greg.1.anderson commentedI don't understand this output:
What output do you see when you run
drush sql-sync @dev.tetoki @tetoki -s? Do you have /private/tmp set somewhere, e.g. some $option setting in drushrc.php? Make sure that this path exists on both servers, and is writable. Drush sql-sync is not good about making appropriate temporary files for the remote server. Temp files are created and named locally, and then used on the remote machine. This can cause problems. Perhaps this is what is going on with your setup, since it looks like the db settings are being fetched w/out problem.Comment #4
garethhallnz commentedI have not setup any $options in drushrc.php. Truth be told I don't now even if I should setup some stuff in there?
I also have not setup /private/tmp ..... I though about setting it up but was not sure where is it relative to drupal root?
drush command: drush sql-sync @dev.tetoki @tetoki -s
Comment #5
drhus commentedsame problem!!
Comment #6
greg.1.anderson commentedNot sure what's going on here; if sql-conf works, then so should sql-sync. Have you tried with 5.x-dev too?
Comment #7
stockliasteroid commentedI had a similar issue, though I don't think it's identical... I believe the solution is covered here (http://drupal.org/node/930124).
I had both my @dev (source) and @staging (destination) aliases defined in sitename.aliases.drushrc.php in the root of my Drupal install, and I couldn't do a sql-sync between @dev and @staging. (drush sql-sync @dev @staging) without it reporting that it couldn't find a database record for @dev. However, if I did "drush sql-conf @dev" I would get the expected output. Ditto for @staging. In my case, I ended up moving the @dev alias definition out of my site-specific aliases file and into my .drush/aliases.drushrc.php file. It seems that the @dev site wasn't getting bootstrapped in time, so sql-sync never had the DB definition in order to do the sync.
Hoping this will help someone else, as it has me stuck for a couple of hours.
Comment #8
garethhallnz commentedRight so I thought I will upgrade drush and try this again.
I am now running drush 4.4 and still the same issue.
Comment #9
alduya commentedI'm having the same problem.
'drush sql-sync default @sitealias' results in:
'drush sql-sync default @sitealias -s' results in:
'drush sql-conf default' results in:
I tried using drush-5.x-dev, but that did not help.
I wonder if it can have anything to do with the fact that I'm using MAMP for development. If us the 'mysql' command, I'm not able to 'show databases' any databases, but I can see them when I 'drush sql-cli' and then 'show databases'.
I hope this info helps you to help me.
Comment #10
garethhallnz commentedInterestingly I to use MAMP well actually MAMP PRO but the server part is the same core I believe. Perhaps it is the cause of the problem but on my system I thought I had accounted the the issue by adding the below to my .profile file.
But perhaps I am wrong
Comment #11
bdone commentedIf it's helpful, I was getting this exact same error and solved it by including (and creating) a %dumps-dir in my remote site's alias:
$aliases['sitename.staging'] = array(
'uri' => 'DOMAIN.COM',
'root' => '/var/www/vhosts/DOMAIN.COM/httpdocs',
'db-url' => 'mysqli://USERNAME:PASSWORD@localhost/DATABASENAME',
'remote-host' => 'DOMAIN.COM',
'remote-user' => 'USERNAME',
'path-aliases' => array(
'%files' => 'sites/default/files',
'%dump-dir' => '/var/www/vhosts/DOMAIN.COM/tmp',
),
);
Comment #12
garethhallnz commentedThank you for everyone who helped I finally have it working
I believe the core things that fixed it was.
1. Upgrading to the latest version of drush
2. Make sure paths are correct in your .profile file if using MAMP see #10
4. Make sure you have a public key setup and working
3. The major one (I think this was my problem all along)
Make sure you aliases file is setup correct and the your temp folder have write premission
This is what my aliases file look like
<?php
$aliases['local.default'] = array(
'path-aliases' => array(
'%files' => 'sites/default/files',
'%dump-dir' => '/Users/username/tmp',
),
);
$aliases['live.default'] = array(
'path-aliases' => array(
'%files' => 'sites/default/files',
'%dump-dir' => '/home/drush_tmp',
),
);
/*** mysite.co.nz ***/
$aliases['dev.mysite'] = array (
'root' => '/Users/username/Sites/mysite.co.nz/public_html',
'uri' => 'dev.mysite.co.nz',
'parent' => '@local.default',
);
$aliases['mysite'] = array (
'uri' => 'mysite',
'root' => '/home/mysite/public_html',
'remote-host' => 'mysite.co.nz',
'remote-user' => 'server-username',
'parent' => '@live.default',
);
Hope this helps someone out.
Comment #13
greg.1.anderson commentedAnyone care to post a patch that improves the drush error message when any of the above is not correct?
Comment #14
wOOge commentedI've been having a similar problem (for background see: http://drupal.org/node/1115048 ).
The following commands fail:
But the following command succeeds:
My aliases file is located at:
Help?
Comment #15
garethhallnz commentedPlease show your aliases file
Comment #16
garethhallnz commentedI am not really sure how a patch would work in this case? I mean I believe the issue was my aliases file and not drushes fault.
Comment #17
greg.1.anderson commented%dump works for me. You should try putting your alias file at a global location, such as $HOME/.drush or /etc/drush. The aliases file above will only be used when a site at that location is bootstrapped.
I'm not sure what the relationship is between %dump not being set and the "no database record could be found for ..." error message (which I do not get, regardless of whether or not %dump is set). If you can figure that one out, it would help a bunch of people. I don't see it, myself.
Comment #18
wOOge commented@greg.1.anderson That was the solution! - I moved the alias file to a global location: $HOME/drush (where drush is running from)
If I have the alias file inside the dev drupal root folder, I get the
Error: no database record could be found forFor the record my alias file is attached in case it helps someone.
Comment #19
moshe weitzman commentedThis requirement to put the alias in a global location for sql-sync is a real gotcha. Any chance we can bootstrap to root if needed? I have not looked at code at all.
Comment #20
greg.1.anderson commentedThere's a chicken-and-the-egg problem with alias files at the root; they will only be found there if cwd or --root is set. I could try a little harder to get these, but it won't always be possible to help folks here.
The real gotcha in this case is the 'no database record could be found' error message. This error is printed out when the alias record cannot be found. sql-sync needs to error out sooner and correctly report that it cannot find the alias record. Finally reproduced this on my end by using an invalid alias -- then it was clear what was going on. In the past, it would correctly say 'alias record not found'; this is a relatively recent breakage (although it has been in 4.x for a while, so not super-recent).
Comment #21
wOOge commentedThanks for all the help and time in diagnosing the issue.
Drush already rocked, now it's even better.
Comment #22
stockliasteroid commentedThe bummer about the bootstrap issue is that it's not possible to include common aliases inside of a site's root folder for inclusion in version control. We're developing with a team, and while the local dev alias may need to be put in .drush for each developer, the staging and live aliases will be the same for everyone. During development it's sometimes handy to do a `drush sql-sync @live @staging` so that we get the latest live data on the staging server, which currently won't work without including the staging alias in .drush instead of in the site's alias file.
Does anyone have a way around this that I'm not thinking of? Ideally I'd like to keep aliases with the site they belong to, not in a monolithic set of aliases in ~/.drush.
Comment #23
moshe weitzman commentedA workaround is to set --alias-path to point to wherever you have checked in the shared aliases. See example.drushrc.php for more info.
Comment #24
blb commentedi've been having this same problem with drush 4.4 and aliases stored in ~/.drush.
one strange thing i've noticed is that sql-sync fails with --simulate=1 with the same error msg:
but when i use --simulate=0 it works fine and no error msg at all!
here is my alias file:
Comment #25
mrfelton commentedsetting simulate to 0 resolves for me too.
Comment #26
greg.1.anderson commentedCommitted to master: http://drupalcode.org/project/drush.git/commit/1ae3a9c
Committed to 7.x-4.x: http://drupalcode.org/project/drush.git/commit/8ec3c2d
Comment #28
dkinzer commented+1 @greg.1.anderson moving the alias file to ~/.drush helped me.
Comment #29
ressaAdding
'%dump-dir' => '/tmp',fixed it for me, like this: