3

drush sql-sync @devyau @stageyau returns:

Call to a member function dump() on a non-object in
/root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc, line
275

echo $PATH returns:

/root/.composer/vendor/bin:/usr/lib64/qt-3.3
/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:
/root/bin

drush @devyau uli returns:

Call to undefined function drush_sql_get_class() 
in /root/.composer/vendor/drush/drush/includes
/environment.inc on line 366

drush @stage uli returns:

call to a member function db_spec() on a non-object in
/root/.composer/vendor/drush/drush/includes/environment.inc, line 370

Here's environment.inc lines 361 to 378:

/**
* Tests the currently loaded database credentials to ensure a 
database connection can be made.
     */
function drush_valid_db_credentials() {
try {
    $sql = drush_sql_get_class();
    if (!$sqlVersion = drush_sql_get_version()) {
      return FALSE;
    }
    if (!$sqlVersion->valid_credentials($sql->db_spec())) {
      return FALSE;
    }
    return $sql->query('SELECT 1;');
  }
  catch (Exception $e) {
    return FALSE;
  }
}

drush ard returns:

The external command could not be executed due to
an application error. Unable to determine sites directory for
devyau. Archive saved to /root/drush-backups/archive-dump/20150703220104
/none.20150703_220105.tar.gz 

drush status returns:

 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /root/.composer/vendor/drush/drush/drush.php
 Drush version          :  7.0.0
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /etc/drush/prodyau.alias.drushrc.php
                           /etc/drush/devyau.alias.drushrc.php
                           /etc/drush/stageyau.alias.drushrc.php

devyau.alias.drush.php:

 <?php
 $aliases['devyau'] = array(
 'uri'=> 'dev.[sitename]',
 'root'=> '/var/www/vhosts/dev.[sitename]/',
 'db-url' => 'mysql://[username]:[password]/devDBname',
  );
?>

stageyau.alias.drush.php:

?php
$aliases['stageyau'] = array(
'uri'=> 'stage.[sitename]',
'root'=> '/var/www/vhosts/stage.[sitename]',
'db-url' => 'mysql://[username]:[password]/[stageDBname]',
  );
 ?>

Been working on this one for a week. Stumped. Any ideas?

2
  • If this isn't a multisite setup and your settings.php file is in the "default" folder and not in dev.[sitename] then I think your uri needs to be set to default, there is a way to set the sites folder to use also, the full status not returning suggest that your site is not bootstrapping correctly so that is probably the issue. I will include some references in an answer in just a bit Jul 4, 2015 at 2:23
  • This is a reference to another question documenting the uri needs to match up with that of the sites/default folder if that is what you are using: drupal.stackexchange.com/questions/15466/… Jul 4, 2015 at 2:26

1 Answer 1

1

Your site doesn't look like it is bootstrapping completely. So I would suggest that you see if drush status will complete in the sites/default or sites/sitename folder. It should look something like the full output below.

A full drush status output

Drupal version                  :  7.38                                                        
Site URI                        :  sitename.com // could be http://default if you have not set your site url                                               
Database driver                 :  mysql                                                       
Database username               :  db_user                                                        
Database name                   :  db_name                                                         
Drupal bootstrap                :  Successful                                                  
Drupal user                     :                                                              
Default theme                   :  default_theme                                                   
Administration theme            :  admin_theme                                                   
PHP executable                  :  /usr/bin/php                                                
PHP configuration               :  /etc/php5/cli/php.ini                                       
PHP OS                          :  Linux                                                       
Drush script                    :  /usr/local/bin/drush-master/drush.php                       
Drush version                   :  8.0-dev                                                     
Drush temp directory            :  /tmp                                                        
Drush configuration             :  /usr/local/bin/drush-master/drushrc.php                     
Drush alias files               :  /usr/local/bin/drush-master/includes/../aliases.drushrc.php 
Install profile                 :  install_profile                                                        
Drupal root                     :  /var/www/html/docroot                                       
Site path                       :  sites/default // Could be sites/sitename.com                                               
File directory path             :  sites/default/files // Same thing here could be sites/sitename.com/files                                                                
Private file directory path     :  /vagrant/private                                            
Temporary file directory path   :  /tmp      

To help this is my alias setup I usually use

This is what I usually use to setup my complete drush alias, it has options that most do not need but it may help someone in the future setup their drush alias that they may have not known existed. If you don't use the "path-aliases" below then you need to use "default" or whatever the "sites/sitename" folder name is named. You can see this in the example alias file from drush.

$remote_sites = '/path/to/site'; // usually /var/www/drupal-root-name
$aliases['site.dev'] = array(
  'uri' => 'sitename.com',
  'remote-host' => '{ip to remote}',
  'remote-user' => '{remote ssh user}',
  'root' => $remote_sites,
  'ssh-options' => '-p {if you ssh in on another port like 2222}',
  'path-aliases' => array(
    '%drush-script' => '/root/.composer/vendor/bin/drush', // This is so you can have multiple drush installs and use different ones on different sites.
    'php'=> '/usr/local/bin/php', // Again if you have different php's for different sites.
    '%site' => 'sites/default/', // This is the important part here, it will ensure the proper bootstrap
    '%dump-dir' => '/path/to/drush.dbdumps', // This is where you want to dump your databases, normally /tmp folder I think.
    '%files' => $remote_sites . '/files' // Your sites file folder, incase it is somewhere else.
  ),
  // You may actually need this, especially if you are running D7 since I haven't ever tested the db-url thing on D7 or above. 
  'databases' => array (
    'default' => array (
      'default' => array (
        'driver' => 'mysql',
        'database' => '{db_name}',
        'username' => '{db_user}',
        'password' => '{db_pass}',
      ),
    ),
  ),
);

After writing the answer I was thinking that this may be a D6 question but I answered assuming the opposite. If that is the case please let me know and I will try to answer for D6 also if there are in fact any differences. Hope this helps, thanks!

2
  • burnsjeremy's "...my alias setup I usually use" solved my problem. My original alias file devyau.alias.drush.php (see above in my question) did not have all the elements required to accomplish a drush sql-sync. Jul 4, 2015 at 18:21
  • Awesome! Glad it worked, I've been meaning to write a blog post about that b/c the example alias file from Drush took me a little bit to wrap my head around since there are so many different examples. Jul 4, 2015 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.