public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); if (false === ($currentBackupStats = backupbuddy_api::getLatestBackupStats())) { return array('api' => '0', 'status' => 'error', 'message' => 'Error #238923: Stats for the latest backup not found. One may have not started yet or stats file is missing.'); } else { return array('version' => '4', 'status' => 'ok', 'message' => 'Latest backup process details retrieved successfully.', 'latestBackupProcess' => $currentBackupStats, 'localTime' => time()); } }
backupbuddy_core::verifyAjaxAccess(); $backupSerial = pb_backupbuddy::_POST('serial'); $profileID = pb_backupbuddy::_POST('profileID'); $thisStep = pb_backupbuddy::_POST('step'); $stepCounter = pb_backupbuddy::_POST('stepCounter'); if ('0' == $thisStep) { $backupFiles = glob(backupbuddy_core::getBackupDirectory() . 'backup*' . $backupSerial . '*.zip'); if (!is_array($backupFiles)) { $backupFiles = array(); } if (count($backupFiles) > 0) { $backupFile = $backupFiles[0]; die(json_encode(array('statusStep' => 'backupComplete', 'stepTitle' => 'Backup finished. File: ' . $backupFile . ' -- Next step start sending the file chunks to remote API server via curl.', 'nextStep' => 'sendFiles'))); } $lastBackupStats = backupbuddy_api::getLatestBackupStats(); if ($backupSerial != $lastBackupStats['serial']) { die(json_encode(array('stepTitle' => 'Waiting for backup to begin.', 'statusStep' => 'waitingBackupBegin'))); } else { // Last backup stats is our deploy backup. die(json_encode(array('stepTitle' => $lastBackupStats['processStepTitle'] . ' with profile "' . pb_backupbuddy::$options['profiles'][$profileID]['title'] . '".', 'statusStep' => 'backupStats', 'stats' => $lastBackupStats))); } } elseif ('sendFiles' == $thisStep) { if ('0' == $stepCounter) { die(json_encode(array('stepTitle' => 'FIRST SENDFILES RUN', 'statusStep' => 'sendFiles', 'nextStep' => 'sendFiles'))); } else { die(json_encode(array('stepTitle' => 'Sending files...', 'statusStep' => 'sendFiles', 'nextStep' => 'sendFiles'))); } } else { die('Invalid step `' . htmlentities($thisStep) . '`.'); }
print_r($_POST); echo '<hr>'; defined('ABSPATH') or die('404 Not Found'); if (!isset(pb_backupbuddy::$options['remote_destinations'][pb_backupbuddy::_POST('destination')])) { die('Error #8457474: Invalid destination ID `' . htmlentities(pb_backupbuddy::_POST('destination')) . '`.'); } $deployment =& pb_backupbuddy::$options['deployments'][pb_backupbuddy::_GET('deployment')]; $profileID = pb_backupbuddy::_POST('backup_profile'); $backupSerial = pb_backupbuddy::random_string(10); // Manually define serial so we can track this specific backup. $backup_result = backupbuddy_api::runBackup($profileID, $triggerTitle = 'Deployment', $backupMode = '', $backupSerial); if (true !== $backup_result) { die('Error #85487755: Unable to start backup. Details: `' . $backup_result . '`.'); } print_r(backupbuddy_api::getLatestBackupStats()); ?> <script> function checkDeployStatus( step ) { jQuery('#pb_backupbuddy_loading').show(); if ( '' == step ) { step = '0'; } stepCounter = 0; // How many status checks of this step have been done. jQuery.ajax({ url: '<?php echo pb_backupbuddy::ajax_url('deploy_status'); ?>