sync.sql.inc

  1. 6.x commands/sql/sync.sql.inc
  2. 3.x commands/sql/sync.sql.inc
  3. 4.x commands/sql/sync.sql.inc
  4. 5.x commands/sql/sync.sql.inc

Functions

Namesort descending Description
drush_sql_post_sql_sync Apply all post-sync operations that were registered in any pre-sync hook. Follow the pattern of this function to make your own post-sync hook. If changing the database, be sure to also include a pre-sync hook to notify the user of the change that will…
drush_sql_sync
drush_sql_sync_init Sql sync init function. Bootstrap either the source or the destination site. At least one of the sites must be local for this to work; if both sites are remote, then it clearly will not be possible to bootstrap to either of them. If both are local,…
sql_drush_sql_sync_sanitize Sql sync sanitization function. This hook function will sanitize usernames and passwords in the user table when the --sanitize option is used. It is also an example of how to write a database sanitizer for sql sync.

File

commands/sql/sync.sql.inc
View source
  1. <?php
  2. require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc';
  3. /**
  4. * Sql sync init function. Bootstrap either the source or the
  5. * destination site. At least one of the sites
  6. * must be local for this to work; if both sites are remote,
  7. * then it clearly will not be possible to bootstrap to
  8. * either of them. If both are local, the source site is preferred.
  9. */
  10. function drush_sql_sync_init($source = NULL, $destination = NULL) {
  11. // Preflight destination in case it defines the alias used by the source
  12. _drush_sitealias_get_record($destination);
  13. // After preflight, get source and destination settings
  14. $source_settings = drush_sitealias_get_record($source);
  15. $destination_settings = drush_sitealias_get_record($destination);
  16. // Insure that we have database records for the source and destination
  17. // alias records. sitealias_get_databases_from_record will cache the
  18. // database info inside the alias records, and drush_sitealias_set_alias_context
  19. // will copy the database record into the 'alias' context. We do not
  20. // actually use the databases record at this time.
  21. sitealias_get_databases_from_record($source_settings);
  22. sitealias_get_databases_from_record($destination_settings);
  23. // Bootstrap to the source sites being sync'ed if it is local.
  24. // This allows modules enabled in the site to participate in the
  25. // sql-sync hook functions (e.g. to add sanitization operations, etc.).
  26. // If the source is remote and the destination is local, then we
  27. // will determine the sanitization operations after the database
  28. // has been copied.
  29. if (!drush_get_option('deferred-sanitization', FALSE) && drush_get_option(array('sanitize', 'destination-sanitize'), FALSE)) {
  30. $bootstrapped = drush_bootstrap_max_to_sitealias($source_settings);
  31. if ($bootstrapped) {
  32. drush_command_invoke_all('drush_sql_sync_sanitize', $source);
  33. }
  34. else {
  35. drush_set_option('deferred-sanitization', TRUE);
  36. }
  37. }
  38. // By default, sql-sync will do an ordered dump.
  39. // Set --no-ordered-dump to override.
  40. if (!drush_get_option('no-ordered-dump', FALSE)) {
  41. drush_set_option('ordered-dump', TRUE);
  42. }
  43. return TRUE;
  44. }
  45. /**
  46. * Sql sync sanitization function. This hook function will sanitize usernames and
  47. * passwords in the user table when the --sanitize option is used. It is
  48. * also an example of how to write a database sanitizer for sql sync.
  49. *
  50. * To write your own sync hook function, define mymodule_drush_sql_sync_sanitize()
  51. * and follow the form of this function to add your own database
  52. * sanitization operations via the register post-sync op function;
  53. * @see drush_sql_register_post_sync_op(). This is the only thing that the
  54. * sync hook function needs to do; sql-sync takes care of the rest.
  55. *
  56. * The function below has a lot of logic to process user preferences and
  57. * generate the correct SQL regardless of whether Postgres, Mysql,
  58. * Drupal 6 or Drupal 7 is in use. A simpler sanitize function that
  59. * always used default values and only worked with Drupal 6 + mysql
  60. * appears in the drush.api.php. @see hook_drush_sql_sync_sanitize().
  61. */
  62. function sql_drush_sql_sync_sanitize($site) {
  63. $site_settings = drush_sitealias_get_record($site);
  64. $user_table_updates = array();
  65. $message_list = array();
  66. // Sanitize passwords.
  67. $newpassword = drush_get_option(array('sanitize-password', 'destination-sanitize-password'), 'password');
  68. if ($newpassword != 'no') {
  69. $major_version = drush_drupal_major_version();
  70. $pw_op = "";
  71. // In Drupal 6, passwords are hashed via the MD5 algorithm.
  72. if ($major_version == 6) {
  73. $pw_op = "MD5('$newpassword')";
  74. }
  75. // In Drupal 7, passwords are hashed via a more complex algorithm,
  76. // available via the user_hash_password function.
  77. elseif ($major_version >= 7) {
  78. include_once DRUPAL_ROOT . '/includes/password.inc';
  79. include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
  80. $hash = user_hash_password($newpassword);
  81. $pw_op = "'$hash'";
  82. }
  83. if (!empty($pw_op)) {
  84. $user_table_updates[] = "pass = $pw_op";
  85. $message_list[] = "passwords";
  86. }
  87. }
  88. // Sanitize email addresses.
  89. $newemail = drush_get_option(array('sanitize-email', 'destination-sanitize-email'), 'user+%uid@localhost');
  90. if ($newemail != 'no') {
  91. if (strpos($newemail, '%') !== FALSE) {
  92. // We need a different sanitization query for Postgres and Mysql.
  93. $db_driver = $site_settings['databases']['default']['default']['driver'];
  94. if ($db_driver == 'pgsql') {
  95. $email_map = array('%uid' => "' || uid || '", '%mail' => "' || replace(mail, '@', '_') || '", '%name' => "' || replace(name, ' ', '_') || '");
  96. $newmail = "'" . str_replace(array_keys($email_map), array_values($email_map), $newemail) . "'";
  97. }
  98. else {
  99. $email_map = array('%uid' => "', uid, '", '%mail' => "', replace(mail, '@', '_'), '", '%name' => "', replace(name, ' ', '_'), '");
  100. $newmail = "concat('" . str_replace(array_keys($email_map), array_values($email_map), $newemail) . "')";
  101. }
  102. }
  103. $user_table_updates[] = "mail = $newmail";
  104. $message_list[] = 'email addresses';
  105. }
  106. if (!empty($user_table_updates)) {
  107. $sanitize_query = "update users set " . implode(', ', $user_table_updates) . " where uid > 0;";
  108. drush_sql_register_post_sync_op('user-email', dt('Reset !message in user table', array('!message' => implode(' and ', $message_list))), $sanitize_query);
  109. }
  110. }
  111. function drush_sql_sync($source = NULL, $destination = NULL) {
  112. $source_settings = drush_sitealias_get_record($source);
  113. $destination_settings = drush_sitealias_get_record($destination);
  114. // Check to see if this is an sql-sync multiple command (multiple sources and multiple destinations)
  115. $is_multiple = drush_do_multiple_command('sql-sync', $source_settings, $destination_settings);
  116. if ($is_multiple === FALSE) {
  117. // Evaluate the source and destination specifications into options.
  118. // The options from the 'source-*' and 'target-*' aliases are set
  119. // in a drush context that has a lower priority than the command-line
  120. // options; this allows command-line options to override the default
  121. // values specified in a site-alias.
  122. drush_sitealias_set_alias_context($source_settings, 'source-');
  123. drush_sitealias_set_alias_context($destination_settings, 'target-');
  124. // Get the options for the source and target databases
  125. $source_db_url = _drush_sql_get_spec_from_options('source-', FALSE);
  126. // The host may have special ssh requirements
  127. $source_remote_ssh_options = drush_get_option('source-ssh-options');
  128. // rsync later will also have to know this option
  129. $source_rsync_options = array('ssh-options' => $source_remote_ssh_options);
  130. $target_db_url = _drush_sql_get_spec_from_options('target-', FALSE);
  131. // The host may have special ssh requirements
  132. $target_remote_ssh_options = drush_get_option('target-ssh-options');
  133. // rsync later will also have to know this option
  134. $target_rsync_options = array('ssh-options' => $target_remote_ssh_options);
  135. if (empty($source_db_url)) {
  136. if (empty($source_settings)) {
  137. return drush_set_error('DRUSH_ALIAS_NOT_FOUND', dt('Error: no alias record could be found for !source', array('!source' => $source)));
  138. }
  139. return drush_set_error('DRUSH_DATABASE_NOT_FOUND', dt('Error: no database record could be found for !source', array('!source' => $source)));
  140. }
  141. if (empty($target_db_url)) {
  142. if (empty($destination_settings)) {
  143. return drush_set_error('DRUSH_ALIAS_NOT_FOUND', dt('Error: no alias record could be found for !destination', array('!destination' => $destination)));
  144. }
  145. return drush_set_error('DRUSH_DATABASE_NOT_FOUND', dt('Error: no database record could be found for !destination', array('!destination' => $destination)));
  146. }
  147. // Set up the result file and the remote file.
  148. // If the result file is not set, then create a temporary file.
  149. // If the remote file is not set, use the same name for the remote
  150. // and local files and hope for the best.
  151. $source_dump = drush_sql_dump_file($source_db_url, 'source-');
  152. $target_dump = drush_sql_dump_file($target_db_url, 'target-');
  153. $use_temp_files = drush_get_option('temp');
  154. // Only use one dump file if both the source and the target are on the local machine
  155. if (!isset($source_db_url['remote-host']) && !isset($target_db_url['remote-host'])) {
  156. if ((!$target_db_url['dump-is-temp']) && ($source_db_url['dump-is-temp'])) {
  157. $source_dump = $target_dump;
  158. $source_db_url['dump-is-temp'] = FALSE;
  159. }
  160. else {
  161. $target_dump = $source_dump;
  162. $target_db_url['dump-is-temp'] = $source_db_url['dump-is-temp'];
  163. }
  164. $local_file = $source_dump;
  165. }
  166. else {
  167. // If one of the systems is remote, then set the --remove-source-files
  168. // rsync option if the source dump file is temporary. This will get
  169. // rsync to clean up after us automatically; useful if the source is remote.
  170. if ($source_db_url['dump-is-temp']) {
  171. $source_rsync_options['remove-source-files'] = TRUE;
  172. }
  173. // Set $local_file to whichever side of the operation is local, or make
  174. // a temporary file if both source and target are remote.
  175. if (!isset($source_db_url['remote-host'])) {
  176. $local_file = $source_dump;
  177. }
  178. elseif (!isset($target_db_url['remote-host'])) {
  179. $local_file = $target_dump;
  180. }
  181. else {
  182. $local_file = drush_tempnam($source_db_url['database'] . ($source_db_url['database'] == $target_db_url['database'] ? '' : '-to-' . $target_db_url['database']) . '.sql.');
  183. }
  184. }
  185. // If source is remote, then use ssh to dump the database and then rsync to local machine
  186. // If source is local, call drush_sql_dump to dump the database to local machine
  187. // In either case, the '--no-dump' option will cause the sql-dump step to be skipped, and
  188. // we will import from the existing local file (first using rsync to fetch it if it does not exist)
  189. //
  190. // No dump affects both local and remote sql-dumps; it prevents drush sql-sync
  191. // from calling sql-dump when the local cache file is newer than the cache threshhold
  192. // No sync affects the remote sql-dump; it will prevent drush sql-sync from
  193. // rsyncing the local sql-dump file with the remote sql-dump file.
  194. $no_sync = drush_get_option(array('no-sync', 'source-no-sync'));
  195. $no_dump = drush_get_option(array('no-dump', 'source-no-dump'));
  196. $no_cache = drush_get_option(array('no-cache', 'source-no-cache'));
  197. if (!isset($no_cache)) {
  198. $cache = drush_get_option(array('cache', 'source-cache'));
  199. if (!isset($cache)) {
  200. $cache = 24; // Default cache is 24 hours if nothing else is specified.
  201. }
  202. }
  203. // If the 'cache' option is set, then we will set the no-dump option iff the
  204. // target file exists and its modification date is less than "cache" hours.
  205. if (isset($cache)) {
  206. if (file_exists($local_file) && (filesize($local_file) > 0)) {
  207. if ((time() - filemtime($local_file)) < ($cache * 60 * 60)) {
  208. drush_log(dt('Modification time of local dump file !file is less than !cache hours old. Use the --no-cache option to force a refresh.', array('!file' => $local_file, '!cache' => $cache)), 'warning');
  209. $no_dump = TRUE;
  210. $no_sync = TRUE;
  211. }
  212. else {
  213. drush_log(dt('Local sql cache file exists but is greater than !cache hours old.', array('!cache' => $cache)));
  214. }
  215. }
  216. else {
  217. drush_log('Local sql cache file does not exist.');
  218. }
  219. }
  220. $table_selection = array();
  221. if (!isset($no_dump)) {
  222. $table_selection = drush_sql_get_table_selection();
  223. }
  224. // Prompt for confirmation. This is destructive.
  225. if (!drush_get_context('DRUSH_SIMULATE')) {
  226. // Check to see if we are using a temporary file in a situation
  227. // where the user did not specify "--temp".
  228. if (($source_db_url['dump-is-temp'] || $target_db_url['dump-is-temp']) && (!isset($use_temp_files)) && (isset($source_db_url['remote-host']) || isset($target_db_url['remote-host']))) {
  229. drush_print(dt('WARNING: Using temporary files to store and transfer sql-dump. It is recommended that you specify --source-dump and --target-dump options on the command line, or set \'%dump\' or \'%dump-dir\' in the path-aliases section of your site alias records. This facilitates fast file transfer via rsync.'));
  230. }
  231. if (array_key_exists('tables', $table_selection) && (count($table_selection['tables']) > 0)) {
  232. drush_print();
  233. drush_print(dt(' Only the following tables will be transferred: !list', array('!list' => implode(',', $table_selection['tables']))));
  234. }
  235. elseif (!empty($table_selection)) {
  236. $skip_tables_list = implode(',', $table_selection['skip'] + $table_selection['structure']);
  237. if(!empty($skip_tables_list)) {
  238. drush_print();
  239. drush_print(dt(' The following tables will be skipped: !list', array('!list' => $skip_tables_list)));
  240. }
  241. }
  242. // If there are multiple destinations, then
  243. // prompt once here and suppress the warning message
  244. // and the normal confirmation below.
  245. if (array_key_exists('site-list', $destination_settings)) {
  246. drush_print();
  247. drush_print(dt('You are about to sync the database from !source, overwriting all of the following targets:', array('!source' => $source)));
  248. foreach ($destination_settings['site-list'] as $one_destination) {
  249. drush_print(dt(' !target', array('!target' => $one_destination)));
  250. }
  251. }
  252. else {
  253. drush_print();
  254. $txt_source = (isset($source_db_url['remote-host']) ? $source_db_url['remote-host'] . '/' : '') . $source_db_url['database'];
  255. $txt_destination = (isset($target_db_url['remote-host']) ? $target_db_url['remote-host'] . '/' : '') . $target_db_url['database'];
  256. drush_print(dt("You will destroy data from !target and replace with data from !source.", array('!source' => $txt_source, '!target' => $txt_destination)));
  257. }
  258. // If any sanitization operations are to be done, then get the
  259. // sanitization messages and print them as part of the confirmation.
  260. // If --sanitize was specified but there were no sanitize messages,
  261. // then warn that sanitization operations will be accumulated and
  262. // processed after the sync completes.
  263. $messages = _drush_sql_get_post_sync_messages();
  264. if ($messages) {
  265. drush_print();
  266. drush_print($messages);
  267. }
  268. else if (drush_get_option('deferred-sanitization', FALSE) && !drush_get_option('confirm-sanitizations', FALSE)) {
  269. drush_print();
  270. drush_print("WARNING: --sanitize was specified, but deferred (e.g. the source site is remote). The sanitization operations will be determined after the database is copied to the local system and will be run without further confirmation. Run with --confirm-sanitizations to force confirmation after the sync.");
  271. }
  272. // TODO: actually make the backup if desired.
  273. drush_print();
  274. drush_print(dt("You might want to make a backup first, using the sql-dump command.\n"));
  275. if (!drush_confirm(dt('Do you really want to continue?'))) {
  276. return drush_user_abort();
  277. }
  278. }
  279. if (isset($source_db_url['remote-host'])) {
  280. $source_remote_user = drush_get_option('source-remote-user');
  281. $source_at = '';
  282. if (isset($source_remote_user)) {
  283. $source_at ='@';
  284. $source_remote_pass = drush_get_option('source-remote-pass') ? ':' . drush_get_option('source-remote-pass') : '';
  285. }
  286. if (!isset($no_dump)) {
  287. $source_intermediate = $source_dump;
  288. $mv_intermediate = '';
  289. // If we are doing a remote dump and the source is not a temporary file,
  290. // then first dump to a temporary file and move it to the specified file after
  291. // the dump is complete. This will reduce contention during simultaneous dumps
  292. // from different users sharing the same dump file.
  293. if (!$source_db_url['dump-is-temp']) {
  294. $source_intermediate = $source_dump . '-' . date("U");
  295. $mv_intermediate = '; mv -f ' . $source_intermediate . ' ' . $source_dump;
  296. }
  297. drush_set_option('result-file', $source_intermediate);
  298. list($dump_exec, $dump_file) = drush_sql_build_dump_command($table_selection, $source_db_url);
  299. $dump_exec .= $mv_intermediate;
  300. if (isset($cache) && !$source_db_url['dump-is-temp']) {
  301. // Inject some bash commands to remotely test the modification date of the target file
  302. // if the cache option is set.
  303. $dump_exec = 'if [ ! -s ' . $source_dump . ' ] || [ $((`date "+%s"`-`stat --format="%Y" ' . $source_dump . '`)) -gt ' . ($cache * 60 * 60) . ' ] ; then ' . $dump_exec . '; fi';
  304. }
  305. $dump_exec = "ssh $source_remote_ssh_options $source_remote_user$source_at" . $source_db_url['remote-host'] . " " . escapeshellarg($dump_exec);
  306. }
  307. }
  308. else {
  309. if (!isset($no_dump)) {
  310. drush_set_option('result-file', $local_file);
  311. list($dump_exec, $dump_file) = drush_sql_build_dump_command($table_selection, $source_db_url);
  312. }
  313. $no_sync = TRUE;
  314. }
  315. // Call sql-dump, either on the local machine or remotely via ssh, as appropriate.
  316. if (!empty($dump_exec)) {
  317. if (drush_op_system($dump_exec)) {
  318. return drush_set_error('DRUSH_SQL_DUMP_FAIL', 'Database dump failed');
  319. }
  320. }
  321. // If the sql-dump was remote, then rsync the file over to the local machine.
  322. if (!isset($no_sync)) {
  323. // If the source file is a temporary file, then we will have rsync
  324. // delete it for us (remove-source-files option set above).
  325. if (!drush_core_call_rsync($source_remote_user . $source_at . $source_db_url['remote-host'] . ':' . $source_dump, $local_file, $source_rsync_options)) {
  326. return FALSE;
  327. }
  328. }
  329. // We will handle lists of destination sites differently from
  330. // single source-to-destination syncs.
  331. if (array_key_exists('site-list', $destination_settings)) {
  332. // Insure that we will not dump the source sql database
  333. // repeatedly, but will instead re-use it each time through
  334. // the redispatch loop.
  335. drush_set_option('no-dump', TRUE);
  336. drush_set_option('no-sync', TRUE);
  337. drush_set_option('source-dump', $source_dump);
  338. // Call sql-sync for each destination to push the $source_dump
  339. // to each target in turn.
  340. foreach ($destination_settings['site-list'] as $one_destination) {
  341. drush_do_command_redispatch('sql-sync', array($source, $one_destination));
  342. }
  343. }
  344. else {
  345. // Prior to database import, we will generate a "create database" command
  346. // if the '--create-db' option was specified. Note that typically the
  347. // web server user will not have permissions to create a database; to specify
  348. // a different user to use with the create db command, the '--db-su' option
  349. // may be used.
  350. // Under postgres, "alter role username with createdb;" will give create database
  351. // permissions to the specified user if said user was not created with this right.
  352. $pre_import_commands = '';
  353. $create_db = drush_get_option('create-db');
  354. if (isset($create_db)) {
  355. $create_db_su = drush_sql_su($target_db_url);
  356. $db_su_connect = _drush_sql_connect($create_db_su);
  357. $pre_import_sql = drush_sql_build_createdb_sql($target_db_url);
  358. $pre_import_commands = sprintf('echo "%s" | %s; ', $pre_import_sql, $db_su_connect);
  359. }
  360. // Generate the import command
  361. $import_command = _drush_sql_connect($target_db_url);
  362. switch (_drush_sql_get_scheme($target_db_url)) {
  363. case 'mysql':
  364. $import_command .= ' --silent';
  365. break;
  366. case 'pgsql':
  367. $import_command .= ' -q';
  368. break;
  369. }
  370. // If destination is remote, then use rsync to push the database, then use ssh to import the database
  371. // If destination is local, then just import the database locally
  372. if (isset($target_db_url['remote-host'])) {
  373. $target_remote_user = drush_get_option('target-remote-user');
  374. $target_at = '';
  375. if (isset($target_remote_user)) {
  376. $target_at ='@';
  377. $target_remote_pass = drush_get_option('target-remote-pass') ? ':' . drush_get_option('target-remote-pass') : '';
  378. }
  379. if (!drush_core_call_rsync($local_file, $target_remote_user . $target_at . $target_db_url['remote-host'] . ':' . $target_dump, $target_rsync_options)) {
  380. return FALSE;
  381. }
  382. $connect_exec = $pre_import_commands . $import_command . ' < ' . $target_dump;
  383. $import_exec = "ssh $target_remote_ssh_options $target_remote_user$target_at" . $target_db_url['remote-host'] . ' ' . escapeshellarg($connect_exec);
  384. // delete the remote target file if it is a temporary file
  385. if ($target_db_url['dump-is-temp']) {
  386. $import_exec .= '; rm -f ' . escapeshellarg($target_dump);
  387. }
  388. }
  389. else {
  390. $import_exec = $pre_import_commands . $import_command . ' < ' . $local_file;
  391. }
  392. drush_op_system($import_exec);
  393. // After the database is imported into the destination, we
  394. // will check and see if we did not collect sanitization
  395. // operations in drush_sql_sync_init (i.e. because the source
  396. // site was remote), and if the destination site is local,
  397. // then we will call the sanitization hooks now.
  398. // This presumes an important precondition, that the code
  399. // files were sync'ed before the database was sync'ed.
  400. if (drush_get_option('deferred-sanitization', FALSE) && (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_SITE) == FALSE)) {
  401. $bootstrapped = drush_bootstrap_max_to_sitealias($destination_settings);
  402. if ($bootstrapped) {
  403. drush_command_invoke_all('drush_sql_sync_sanitize', $destination);
  404. }
  405. }
  406. }
  407. }
  408. }
  409. /**
  410. * Apply all post-sync operations that were registered in any pre-sync hook.
  411. * Follow the pattern of this function to make your own post-sync hook.
  412. * If changing the database, be sure to also include a pre-sync hook to
  413. * notify the user of the change that will be made. @see drush_sql_pre_sql_sync().
  414. */
  415. function drush_sql_post_sql_sync($source = NULL, $destination = NULL) {
  416. $options = drush_get_context('post-sync-ops');
  417. if (!empty($options)) {
  418. // If 'deferred-sanitization' is set, then we collected the
  419. // sanitization operations -after- the database sync, which
  420. // means they were not confirmed up-front. We will show the
  421. // operations here, but we will not offer an opportunity to
  422. // confirm unless --confirm-sanitizations is specified.
  423. if (drush_get_option('deferred-sanitization', FALSE) || drush_get_option('confirm-sanitizations', FALSE)) {
  424. if (!drush_get_context('DRUSH_SIMULATE')) {
  425. $messages = _drush_sql_get_post_sync_messages();
  426. if ($messages) {
  427. drush_print();
  428. drush_print($messages);
  429. if (drush_get_option('confirm-sanitizations', FALSE)) {
  430. if (!drush_confirm(dt('Do you really want to sanitize?'))) {
  431. // Do not abort or return FALSE; that would trigger a rollback.
  432. // Just skip the sanitizations and signal that all is ok.
  433. drush_log(dt('Sanitizations skipped.'), 'ok');
  434. return TRUE;
  435. }
  436. }
  437. }
  438. }
  439. }
  440. $destination_settings = drush_sitealias_get_record($destination);
  441. $sanitize_query = '';
  442. foreach($options as $id => $data) {
  443. $sanitize_query .= $data['query'] . " ";
  444. }
  445. if ($sanitize_query) {
  446. if (!drush_get_context('DRUSH_SIMULATE')) {
  447. $result = drush_invoke_sitealias_args($destination_settings, "sql-query", array($sanitize_query));
  448. }
  449. else {
  450. drush_print("Executing on $destination: $sanitize_query");
  451. }
  452. }
  453. }
  454. }