public function deploy_pull_renderImportBuddy($state) { if (!file_exists($state['pullLocalArchiveFile'])) { pb_backupbuddy::status('error', 'Error #32783732: Backup file `' . $state['pullLocalArchiveFile'] . '` not found.'); return false; } $backupSerial = backupbuddy_core::get_serial_from_file($state['pullLocalArchiveFile']); $importbuddyPassword = md5(md5($state['destination']['key_public'])); $siteurl = site_url(); $additionalStateInfo = array(); $importFileSerial = backupbuddy_core::deploymentImportBuddy($importbuddyPassword, $state['pullLocalArchiveFile'], $additionalStateInfo); if (is_array($importFileSerial)) { // Could not generate importbuddy file. return false; } // Store this serial in settings to cleanup any temp db tables in the future with this serial with periodic cleanup. pb_backupbuddy::$options['rollback_cleanups'][$backupSerial] = time(); pb_backupbuddy::save(); // Create undo file. $undoFile = 'backupbuddy_deploy_undo-' . $backupSerial . '.php'; if (false === copy(pb_backupbuddy::plugin_path() . '/classes/_rollback_undo.php', ABSPATH . $undoFile)) { $error = 'Error #3289447: Unable to write undo file `' . ABSPATH . $undoFile . '`. Check permissions on directory.'; pb_backupbuddy::status('error', $error); return false; } // Start pulling importbuddy log. $importbuddyURLRoot = $siteurl . '/importbuddy-' . $importFileSerial . '.php'; $importbuddyLogURL = $importbuddyURLRoot . '?ajax=getDeployLog&v=' . $importbuddyPassword . '&deploy=true'; //$state['destination']['siteurl'] . '/importbuddy/'?ajax=2&v=' . $importbuddyPassword . '&deploy=true; //status-' . $response['importFileSerial'] . '.txt'; $importbuddyURL = $importbuddyURLRoot . '?ajax=2&v=' . $importbuddyPassword . '&deploy=true&direction=pull&file=' . basename($state['pullLocalArchiveFile']); pb_backupbuddy::status('details', 'Load importbuddy at `' . $importbuddyURLRoot . '` with verifier `' . $importbuddyPassword . '`.'); pb_backupbuddy::status('loadImportBuddy', json_encode(array('url' => $importbuddyURL, 'logurl' => $importbuddyLogURL))); // Calculate undo URL. $undoDeployURL = $siteurl . '/backupbuddy_deploy_undo-' . $this->_backup['serial'] . '.php'; pb_backupbuddy::status('details', 'To undo deployment of database contents go to the URL: ' . $undoDeployURL); pb_backupbuddy::status('undoDeployURL', $undoDeployURL); // Pull importbuddy log instead of remote backup log. Nothing else is going to be done on remote server. $this->_backup_options->options['deployment_log'] = $importbuddyLogURL; $this->_backup_options->save(); // Next step. pb_backupbuddy::status('details', 'Inserting deploy step to run importbuddy steps on remote server.'); $newStep = array('function' => 'deploy_runningImportBuddy', 'args' => array($state), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0); $this->insert_next_step($newStep); return true; }
private static function _verb_renderImportBuddy() { $backupFile = pb_backupbuddy::_POST('backupFile'); $password = md5(md5(pb_backupbuddy::_POST('backupbuddy_api_key'))); // Store this serial in settings to cleanup any temp db tables in the future with this serial with periodic cleanup. $backupSerial = backupbuddy_core::get_serial_from_file($backupFile); pb_backupbuddy::$options['rollback_cleanups'][$backupSerial] = time(); pb_backupbuddy::save(); $importFileSerial = backupbuddy_core::deploymentImportBuddy($password, backupbuddy_core::getBackupDirectory() . $backupFile); if (is_array($importFileSerial)) { die(json_encode(array('success' => false, 'error' => $importFileSerial[1]))); } else { die(json_encode(array('success' => true, 'importFileSerial' => $importFileSerial))); } }
private static function _verb_renderImportBuddy() { $backupFile = pb_backupbuddy::_POST('backupFile'); $password = md5(md5(pb_backupbuddy::_POST('backupbuddy_api_key'))); $importFileSerial = backupbuddy_core::deploymentImportBuddy($password, backupbuddy_core::getBackupDirectory() . $backupFile); if (is_array($importFileSerial)) { die(json_encode(array('success' => false, 'error' => $importFileSerial[1]))); } else { die(json_encode(array('success' => true, 'importFileSerial' => $importFileSerial))); } }