1

It seems that the structure tables dont work on a sql sync from my live site to my dev. Using the following comman:

drush sql-sync @example.live @example.dev

The search_api_server is every time overritten, so it gets synced. So i think also my cache tables get synced. Whats wrong with my aliases?

/**
 * Dev/Local alias
 */
$aliases['dev'] = array(
  'root' => '/var/www/example_dev',
  'uri'  => 'example.dev',
  'path-aliases' => array(
    '%files' => 'sites/default/files',
  ),
  'source-command-specific' => array (
    'sql-sync' => array (
      'no-cache' => TRUE,
      'structure-tables-key' => 'common',
    ),
  ),
  // No need to modify the following settings
  'command-specific' => array (
    'sql-sync' => array (
      'sanitize' => TRUE,
      'no-ordered-dump' => TRUE,
      'structure-tables' => array(
       // You can add more tables which contain data to be ignored by the database dump
        'common' => array('cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog','search_api_server'),
      ),
    ),
  ),
);

/**
 * Live alias
 */
$aliases['live'] = array(
  'remote-host' => '000.000.00.00',
  'remote-user' => 'username',
  'root' => '/var/www/html/example-live',
  'uri'  => 'example.net',
  'path-aliases' => array(
    '%files' => 'sites/default/files',
  ),
);
0

There are three places you can reference aliases when using sql-sync:

drush @site sql-sync @prod @dev

@site - Where the sql-sync will execute. If this is a remote site, then the other two aliases must be defined in files that reside on the remote machine. Options from 'command-specific' will be applied to the command.

@prod - The source for the sync. Options from 'source-command-specific' will be applied to the command.

@dev - The target for the sync. Options from 'target-command-specific' will be applied to the command.

The alias @site is not usually used with sql-sync; most people just run drush sql-sync @prod @dev.

Drush is going to look for different 'command-specific' records depending on the position of the alias appears on the commandline.

@site - The alias that appears before the command name will have options from the 'command-specific' -> 'sql-sync' record added to the evaluated options list.

@prod - The alias that appears in the first position after the command name will have options from the 'source-command-specific' -> 'sql-sync' record used.

@dev - The alias that appears in the second position after the command name will have options from the 'target-command-specific' -> 'sql-sync' record used.

In the typical case (drush sql-sync @prod @dev), the 'command-specific' record is not used at all, the 'source-command-specific' record from @prod is used, and the 'target-command-specific' record from @dev is used.

Try using alias records more like the following set:

/**
 * Dev/Local alias
 */
$aliases['dev'] = array(
  'root' => '/var/www/example_dev',
  'uri'  => 'example.dev',
  'path-aliases' => array(
    '%files' => 'sites/default/files',
  ),
  'target-command-specific' => array (
    'sql-sync' => array (
      'no-cache' => TRUE,
      'structure-tables-list' => 'cache,cache_admin_menu,cache_block,cache_bootstrap',
      ),
    ),
  ),
);

/**
 * Live alias
 */
$aliases['live'] = array(
  'remote-host' => '000.000.00.00',
  'remote-user' => 'username',
  'root' => '/var/www/html/example-live',
  'uri'  => 'example.net',
  'path-aliases' => array(
    '%files' => 'sites/default/files',
  ),
  'source-command-specific' => array (
    'sql-sync' => array (
      'sanitize' => TRUE,
      'no-ordered-dump' => TRUE,
    ),
  ),
);
| improve this answer | |
  • Thanks for the answer but i dont understand all of it. – kitikonti Mar 23 '15 at 20:42
  • In the documentation of drush sql-sync the command is described like this: drush sql-sync @prod @dev So what is? drush @site sql-sync @live @dev In my case live is remote and dev is the local machine, as you can see in the alias file. And what do you mean with: It is unusual for anyone to use the alias in the first position with sql-sync. – kitikonti Mar 23 '15 at 20:50
  • I expanded my answer for better clarity. – greg_1_anderson Mar 24 '15 at 16:22

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.