clone.provision.inc

  1. 7.x-3.x platform/clone.provision.inc
  2. 7.x-3.x db/clone.provision.inc

Functions

Namesort descending Description
drush_provision_drupal_pre_provision_clone Make a backup before making any changes, and add extract the file we are restoring from
drush_provision_drupal_pre_provision_clone_rollback Remove the extracted site directory
drush_provision_drupal_provision_clone Switch the clone directories around now that we have the new db installed
drush_provision_drupal_provision_clone_validate Make sure we have a valid site being cloned, and that the file being cloned from exists

File

platform/clone.provision.inc
View source
  1. <?php
  2. /**
  3. * Clone command implementation
  4. *
  5. * This command when called will
  6. * 1. Make a backup of the current site, before modifications are made.
  7. * 2. Execute 'provision deploy' to build the new site using the backup of the old site.
  8. *
  9. */
  10. /**
  11. * Make sure we have a valid site being cloned, and that the file being cloned from exists
  12. */
  13. function drush_provision_drupal_provision_clone_validate($new_name = null, $platform = null) {
  14. drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
  15. }
  16. /**
  17. * Make a backup before making any changes, and add extract the file we are restoring from
  18. */
  19. function drush_provision_drupal_pre_provision_clone($new_name, $platform = null) {
  20. drush_invoke('provision-backup');
  21. }
  22. /**
  23. * Remove the extracted site directory
  24. */
  25. function drush_provision_drupal_pre_provision_clone_rollback($new_name, $platform = null) {
  26. $success = provision_file()->unlink(drush_get_option('backup_file'))
  27. ->succeed('Removed unused clone site package')
  28. ->fail('Could not remove unused clone site package');
  29. }
  30. /**
  31. * Switch the clone directories around now that we have the new db installed
  32. */
  33. function drush_provision_drupal_provision_clone($new_name, $platform = null) {
  34. drush_set_option('old_platform', d()->platform->name);
  35. $options = d()->options;
  36. $options['uri'] = ltrim($new_name, '@');
  37. $hash_name = drush_get_option('#name') ? '#name' : 'name';
  38. $options[$hash_name] = $new_name;
  39. $options['platform'] = (isset($platform)) ? $platform : $options['platform'];
  40. $options['root'] = d($options['platform'])->root;
  41. $options['aliases'] = array();
  42. $options['redirection'] = 0;
  43. // XXX: right now we just drop SSL configuration when cloning, because
  44. // we do not check if the site name change is compatible with the
  45. // certificate. This can be removed when we a) check for wildcard
  46. // certs and b) allow the user to change the cert from the UI.
  47. $options['ssl_enabled'] = 0;
  48. unset($options['ssl_key']);
  49. // Do not copy CDN aliases to the cloned site --CDN vhost
  50. $options['cdn'] = 0;
  51. unset($options['cdn']);
  52. if ($profile = drush_get_option('profile', FALSE)) {
  53. $options['profile'] = $profile;
  54. }
  55. if ($db_server = drush_get_option('new_db_server', FALSE)) {
  56. $options['db_server'] = $db_server;
  57. }
  58. drush_invoke_process('@none', 'provision-save', array($new_name), $options);
  59. # note that we reset the aliases so they don't conflict with the original site
  60. // Build an options array to pass to the deploy task. This allows injection
  61. // of data into the deploy task. See: https://www.drupal.org/node/2471805
  62. $deploy_options = array(
  63. 'old_uri' => d()->uri,
  64. 'strict' => 0,
  65. );
  66. drush_command_invoke_all_ref('provision_deploy_options_alter', $deploy_options, 'clone');
  67. provision_backend_invoke($new_name, 'provision-deploy', array(drush_get_option('backup_file')), $deploy_options);
  68. if (!drush_get_error()) {
  69. provision_backend_invoke($new_name, 'provision-verify');
  70. }
  71. provision_reload_config('site', d()->site_path . '/drushrc.php');
  72. }