Esempio n. 1
0
 }
 // Restore the database.
 if ('true' == pb_backupbuddy::_GET('deploy')) {
     // Drop any previous incomplete deployment / rollback tables.
     pb_backupbuddy::status('details', 'Dropping any existing temporary deployment or rollback tables.');
     if (false !== ($results = mysql_query("SELECT table_name FROM information_schema.tables WHERE ( ( table_name LIKE 'bbnew-\\_%' ) OR ( table_name LIKE 'bbold-\\_%' ) ) AND table_schema = DATABASE()"))) {
         while ($result = mysql_fetch_row($results)) {
             if (false === mysql_query("DROP TABLE `" . mysql_real_escape_string($result[0]) . "`")) {
                 pb_backupbuddy::status('details', 'Error #8493984: Unable to drop temp rollback/deploy table `' . $result['table_name'] . '`.');
             }
         }
     }
     $restore->_state['databaseSettings']['tempPrefix'] = 'bbnew-' . substr($restore->_state['serial'], 0, 4) . '_' . $restore->_state['databaseSettings']['prefix'];
 }
 pb_backupbuddy::status('details', 'About to restore database.');
 $restoreResult = $restore->restoreDatabase($restore->_state['databaseSettings']['tempPrefix']);
 if ('true' == pb_backupbuddy::_GET('deploy')) {
     if (is_array($restoreResult)) {
         // Chunking. Resume same step.
         $nextStepNum = 4;
     } else {
         // Next step.
         $nextStepNum = 5;
     }
     echo '<!-- AUTOPROCEED TO STEP ' . $nextStepNum . ' -->';
     //echo '<script>console.log( "' . print_r( $restore->_state, true ) . '" );</script>';
     // Write default state overrides.
     global $importbuddy_file;
     $importFileSerial = backupbuddy_core::get_serial_from_file($importbuddy_file);
     $state_file = ABSPATH . 'importbuddy-' . $importFileSerial . '-state.php';
     pb_backupbuddy::status('details', 'Writing to state file `' . $state_file . '`.');
Esempio n. 2
0
<?php

// Incoming vars: $backupFile, $step
if (!current_user_can(pb_backupbuddy::$options['role_access'])) {
    die('Error #473623. Access Denied.');
}
//pb_backupbuddy::verify_nonce();
$nextStep = 3;
$restoreData = unserialize(base64_decode(pb_backupbuddy::_POST('restoreData')));
require_once pb_backupbuddy::plugin_path() . '/classes/restore.php';
$rollback = new backupbuddy_restore('rollback', $restoreData);
$status = $rollback->restoreDatabase();
if (false === $status) {
    $errors = $rollback->getErrors();
    if (count($errors) > 0) {
        pb_backupbuddy::alert('Errors were encountered: ' . implode(', ', $errors) . ' If seeking support please click to Show Advanced Details above and provide a copy of the log.');
    }
    return;
} elseif (is_numeric($status)) {
    // Incomplete, has more to import.
    $nextStep = 2;
    // more to do on step 2.
}
$restoreData = $rollback->getState();
?>


<?php 
if (true === $restoreData['autoAdvance']) {
    // Auto-advance if enabled.
    ?>
Esempio n. 3
0
                pb_backupbuddy::status('error', 'Unable to wipe database tables matching prefix.');
            }
        }
    }
    // DANGER: Wipe database of ALL TABLES if option was selected.
    if (TRUE === $restore->_state['databaseSettings']['wipeDatabase']) {
        if (!isset($restore->_state['databaseSettings']['importResumeFiles']) && '' == $restore->_state['databaseSettings']['importResumePoint']) {
            // Only do this if not in process of resuming.
            pb_backupbuddy::status('message', 'Wiping ALL existing database tables based on settings (use with caution)...');
            if (TRUE !== pb_backupbuddy::$classes['import']->wipeDatabase(TRUE)) {
                pb_backupbuddy::status('error', 'Unable to wipe entire database as configured in the settings.');
            }
        }
    }
    // Restore the database.
    if (TRUE !== ($restoreResult = $restore->restoreDatabase())) {
        if (is_array($restoreResult)) {
            pb_backupbuddy::status('details', 'Database restore did not fully complete in first pass. Chunking in progress. Resuming where left off.');
            ?>

			<form id="restoreChunkForm" method="post" action="?ajax=4">
				<input type="hidden" name="restoreData" value="<?php 
            echo base64_encode(urlencode(json_encode($restore->_state)));
            ?>
">
				<input type="submit" name="submitForm" class="button button-primary" value="Next Step" style="display: none;">
			</form>
			<script>
				jQuery(document).ready(function() {
					jQuery( '#restoreChunkForm' ).submit();
				});