restore.provision.inc 1.5 KB
Newer Older
1 2 3 4 5
<?php

/**
 * Make sure we have a valid site being restored, and that the file being restored from exists
 */
6
function drush_provision_drupal_provision_restore_validate($restore_file = null) {
7
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
8

9
  $exists = provision_file()->exists($restore_file)
10 11 12
    ->succeed('Restoring site from @path')
    ->fail('Could not find backup file @path', 'PROVISION_BACKUP_NOT_FOUND')
    ->status();
13
  if ($exists) {
14
    drush_set_option('restore_file', $restore_file);
15 16 17 18 19 20
  }
}

/**
 * Make a backup before making any changes, and add extract the file we are restoring from
 */
21
function drush_provision_drupal_pre_provision_restore($restore_file) {
22
  drush_log(dt("Putting site under maintenance"));
23
  d()->site_enabled = false;
24
  _provision_drupal_create_settings_file();
25
  drush_invoke('provision-backup');
26 27
}

28 29 30 31
function drush_provision_drupal_pre_provision_restore_rollback($restore_file) {
  $success =  provision_file()->unlink(drush_get_option('backup_file'))
    ->succeed('Removed unused migration site package')
    ->fail('Could not remove unused migration site package');
32 33 34 35 36
}

/**
 * Switch the restore directories around now that we have the new db installed
 */
37
function drush_provision_drupal_provision_restore($restore_file) {
38

39
  provision_backend_invoke(d()->name, 'provision-deploy', array(drush_get_option('restore_file')), array('old_uri' => d()->uri));
40 41
  if (!drush_get_error()) {
    provision_backend_invoke(d()->name, 'provision-verify');
42
    drush_set_option('installed', false);
43
  }
44 45
}