/[drupal]/contributions/modules/provision/db_server/restore.provision.inc
ViewVC logotype

Contents of /contributions/modules/provision/db_server/restore.provision.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download) (as text)
Wed Aug 26 01:00:28 2009 UTC (3 months ago) by anarcat
Branch: MAIN
CVS Tags: DRUPAL-6--0-3, DRUPAL-6--0-4-ALPHA1, DRUPAL-6--0-4-ALPHA3, DRUPAL-6--0-4-ALPHA2, HEAD
Changes since 1.10: +1 -1 lines
File MIME type: text/x-php
silence some warnings
1 <?php
2
3 function drush_provision_mysql_provision_restore_validate() {
4 provision_db_connect();
5 }
6
7 function drush_provision_mysql_pre_provision_restore($url = NULL) {
8 $db_type = drush_set_option('db_type', drush_get_option('db_type'));
9 $db_host = drush_set_option('db_host', drush_get_option('db_host'));
10 $db_passwd = drush_set_option('db_passwd', provision_password());
11 $db_name = drush_set_option('db_name', _provision_mysql_suggest_db_name($url));
12 $db_user = drush_set_option('db_user', $db_name);
13
14 _provision_mysql_new_site_db($db_name, $db_user, $db_passwd);
15 }
16
17 function drush_provision_mysql_provision_restore($url) {
18 _provision_mysql_import_dump(
19 drush_get_option('sites_path') .'/'. $url .'/database.sql',
20 drush_get_option('db_name'), drush_get_option('db_user'),
21 drush_get_option('db_passwd'), drush_get_option('db_host')
22 );
23 }
24
25
26 function drush_provision_mysql_pre_provision_restore_rollback($url = NULL) {
27 _provision_mysql_destroy_site_db(drush_get_option('db_name'), drush_get_option('db_user'), drush_get_option('db_passwd'));
28
29 $keys = array('db_name', 'db_passwd', 'db_user', 'db_host');
30
31 //Restore the original database credentials of the site.
32 // They were never truly lost, but the options in the 'process' context
33 // were overriding them. By unsetting the temporary options, the originals
34 // are automatically restored.
35 foreach ($keys as $key) {
36 drush_unset_option($key, 'process');
37 }
38 }
39
40 // Rollback doesn't apply here yet. Unless we trigger a restore of the first dump
41 // made. Which could go on infinitely if something is really long.
42 function drush_provision_mysql_post_provision_restore($url = NULL) {
43 provision_path('unlink', drush_get_option('sites_path') . '/' . $url .'/database.sql', TRUE,
44 dt("Removed dump file @path after restoring from it"),
45 dt("Could not remove dump file @path"), 'DRUSH_PERM_ERROR');
46
47 $db_grant_host = _provision_mysql_grant_host(
48 drush_get_option('db_host', '', 'site'),
49 drush_get_option('web_ip', null, 'site'),
50 drush_get_option('web_host', null, 'site'));
51 // We have now completed successfully, remove the old database.
52 _provision_mysql_destroy_site_db(
53 drush_get_option('db_name', null, 'site'),
54 drush_get_option('db_user', null, 'site'),
55 drush_get_option('db_passwd', null, 'site'),
56 $db_grant_host);
57
58 // The new database credentials will be saved against the site now.
59 drush_set_option('db_name', drush_get_option('db_name'), 'site');
60 drush_set_option('db_type', drush_get_option('db_type'), 'site');
61 drush_set_option('db_user', drush_get_option('db_user'), 'site');
62 drush_set_option('db_host', drush_get_option('db_host'), 'site');
63 drush_set_option('db_passwd', drush_get_option('db_passwd'), 'site');
64 }
65

  ViewVC Help
Powered by ViewVC 1.1.2