<?php // This code runs everywhere. pb_backupbuddy::$options preloaded. // TODO: Remove file check? if (file_exists('destinations/live/live.php')) { foreach (pb_backupbuddy::$options['remote_destinations'] as $destination) { // See if we have Live activated. if ('live' == $destination['type']) { include 'destinations/live/live.php'; backupbuddy_live::init(); break; } } } include 'classes/constants.php'; include 'classes/api.php'; // Handle API calls if backupbuddy_api_key is posted. If anything fails security checks pretend nothing at all happened. if ('' != pb_backupbuddy::_POST('backupbuddy_api_key')) { // Remote API access. if (isset(pb_backupbuddy::$options['remote_api']) && count(pb_backupbuddy::$options['remote_api']['keys']) > 0 && defined('BACKUPBUDDY_API_ENABLE') && TRUE == BACKUPBUDDY_API_ENABLE) { // Verify API is enabled. && defined( 'BACKUPBUDDY_API_SALT' ) && ( 'CHANGEME' != BACKUPBUDDY_API_SALT ) && ( strlen( BACKUPBUDDY_API_SALT ) >= 5 ) include 'classes/remote_api.php'; backupbuddy_remote_api::localCall($secure = true); die; } } // Internal cron (disabled by default). if ('1' == pb_backupbuddy::$options['use_internal_cron'] && 'process_backup' == pb_backupbuddy::_POST('backupbuddy_cron_action')) { // Verify access to trigger cron. if (pb_backupbuddy::$options['log_serial'] != pb_backupbuddy::_POST('backupbuddy_key')) { die('Access Denied.');
<style> </style> <?php /* $types = array( 'media', 'themes', 'plugins', 'custom' ); */ echo '<br>MediaStats:'; $mediaStats = backupbuddy_live::get_file_stats('media'); print_r($mediaStats); echo '<br>ThemeStats:'; $mediaStats = backupbuddy_live::get_file_stats('theme'); print_r($mediaStats); echo '<br>PluginStats:'; $mediaStats = backupbuddy_live::get_file_stats('plugins'); print_r($mediaStats); echo '<br>CustomStats:'; $mediaStats = backupbuddy_live::get_file_stats('custom'); print_r($mediaStats); // Handles thickbox auto-resizing. Keep at bottom of page to avoid issues. if (!wp_script_is('media-upload')) { wp_enqueue_script('media-upload'); wp_print_scripts('media-upload'); }
// If db process running, say so. if ('database_snapshot' == $state['step']['function'] || 'send_pending_db_snapshots' == $state['step']['function'] || 'process_table_deletions' == $state['step']['function']) { $stats['next_db_snapshot'] = '-1'; $stats['next_db_snapshot_pretty'] = __('In Progress...', 'it-l10n-backupbuddy'); } } // Current function. $stats['current_function'] = $state['step']['function']; $stats['current_function_pretty'] = backupbuddy_live::pretty_function($state['step']['function']); if ('database_snapshot' == $state['step']['function']) { // For db dump include current table count. if (count($state['step']['args']) > 0) { $total_tables = count($state['step']['args'][0]); $remaining_tables = count($state['step']['args'][1]); $sent_tables = $total_tables - $remaining_tables; $stats['current_function_pretty'] .= ' (' . $sent_tables . ' / ' . $total_tables . ' ' . __('tables', 'it-l10n-backupbuddy') . ')'; } } // First completion. $stats['first_completion'] = $state['stats']['first_completion']; if (0 != $stats['first_completion']) { $stats['first_completion_pretty'] = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($state['stats']['first_completion'])); $stats['first_completion_ago'] = pb_backupbuddy::$format->time_ago($state['stats']['first_completion']); } // Include Stash stats. Note that these are cached. $stats['stash'] = backupbuddy_live::getStashQuota($bust_cache = false); /* echo '<pre>'; print_r( $stats ); echo '</pre>'; */
<?php // Incoming vars: $pause_continuous, $pause_periodic, $start_run. require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; if (false === ($destination_id = backupbuddy_live::getLiveID())) { // $destination_id used by _stats.php. return false; } $saving = false; /***** BEGIN CONTINOUS *****/ if (false === $pause_continuous) { // Unpause. pb_backupbuddy::$options['remote_destinations'][$destination_id]['pause_continuous'] = '0'; $saving = true; } elseif (true === $pause_continuous) { // Pause. pb_backupbuddy::$options['remote_destinations'][$destination_id]['pause_continuous'] = '1'; $saving = true; } /***** END CONTINOUS *****/ /***** BEGIN PERIODIC *****/ if (false === $pause_periodic) { // Unpause. $prior_periodic_status = pb_backupbuddy::$options['remote_destinations'][$destination_id]['pause_periodic']; pb_backupbuddy::$options['remote_destinations'][$destination_id]['pause_periodic'] = '0'; if ('1' == $prior_periodic_status) { // Was paused, now unpaused, so check if we need to run now. if (true === $start_run) { pb_backupbuddy::save(); // Must save prior to spawning. $cronArgs = array();
<?php backupbuddy_core::verifyAjaxAccess(); pb_backupbuddy::$ui->ajax_header($js = true, $padding = false); require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; $destination_id = backupbuddy_live::getLiveID(); $destination = backupbuddy_live_periodic::get_destination_settings(); $hide_quota = true; $live_mode = true; require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php'; require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/_manage.php'; pb_backupbuddy::$ui->ajax_footer($js_common = true);
private static function _setLiveID() { if ('' == self::$_liveDestinationID) { foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) { if ('live' == $destination['type']) { self::$_liveDestinationID = $destination_id; break; } } if ('' == self::$_liveDestinationID) { pb_backupbuddy::status('error', 'Error #382938932: Fatal error. No Live destination was found configured. Set up BackupBuddy live.'); return false; } } return true; }
<?php if (defined('BACKUPBUDDY_DEV') && true === BACKUPBUDDY_DEV) { echo 'DEV MODE'; /***** DB *****/ //update_option( 'moosetaco', time() ); //backupbuddy_live::run_dbqueue(); /***** FILES *****/ backupbuddy_live::files_init(); return; } if (!defined('pluginbuddy_importbuddy')) { $url = home_url(); } else { $url = str_replace($_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']); $url = str_replace(basename($url), '', $url); $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; } /* $timeoutMinutes = 5; // Minutes after which BackupBuddy assumed a backup has timed out & no longer running. // STATS GENERATION GOES HERE. echo '<pre>'; print_r( $currentBackupStats ); echo '</pre>'; echo '<hr>'; echo '<pre>';
public static function run_live_send() { if (true === self::$_queue_sent) { // Already sent. Shutdown fired again. return; } pb_backupbuddy::flush(); // Send any pending data to browser. if (!isset(pb_backupbuddy::$options['remote_destinations'][backupbuddy_live::getLiveID()])) { // Live destination went away. Deleted? return; } $count = self::_process_dbqueue(); if (0 == $count) { // Nothing needs to be sent. return; } self::_send_dbqueue(); }
pb_backupbuddy::alert(__('Settings saved. Restarting Live process so they take immediate effect.', 'it-l10n-backupbuddy')); set_transient('backupbuddy_live_jump', array('daily_init', array()), 60 * 60 * 48); // Tells Live process to restart from the beginning (if mid-process) so new settigns apply. // Add final entry to log if disabled if ($destination_settings['disable_logging'] == 0 && $save_result['data']['disable_logging'] == 1) { $previous_status_serial = pb_backupbuddy::get_status_serial(); // Hold current serial. pb_backupbuddy::set_status_serial('live_periodic'); // Redirect logging output to a certain log file. pb_backupbuddy::status('details', '-----'); pb_backupbuddy::status('details', 'Logging disabled in Stash Live --> Settings --> Advanced.'); pb_backupbuddy::status('details', '-----'); pb_backupbuddy::set_status_serial($previous_status_serial); } // Send new settings for archive limiting to Stash API. backupbuddy_live::send_trim_settings(); } else { pb_backupbuddy::alert('Error saving settings. ' . implode("\n", $save_result['errors'])); } } // Show settings form. echo $settings_form->display_settings('Save Settings', $before = '', $afterText = ' <img class="pb_backupbuddy_destpicker_saveload" src="' . pb_backupbuddy::plugin_url() . '/images/loading.gif" title="Saving... This may take a few seconds..." style="display: none;">', 'pb_backupbuddy_destpicker_save'); // title, before, after, class if ('live' == $destination_settings['type']) { if (is_multisite()) { $admin_url = network_admin_url('admin.php'); } else { $admin_url = admin_url('admin.php'); } ?> <a href="<?php
public static function _run_remote_snapshot($trigger = 'unknown') { if (false === self::_load_state()) { return false; } $destination_settings = backupbuddy_live_periodic::get_destination_settings(); // Send email notification? if ('1' == $destination_settings['send_snapshot_notification'] || 0 == self::$_state['stats']['first_completion']) { // Email notification enabled _OR_ it's the first snapshot for this site. if ('' != $destination_settings['email']) { $email = $destination_settings['email']; } else { pb_backupbuddy::status('details', 'Snapshot set to send email notification to account. Send notification?: `' . $destination_settings['send_snapshot_notification'] . '`. First completion: `' . self::$_state['stats']['first_completion'] . '`.'); $email = 'account'; } } else { pb_backupbuddy::status('details', 'Snapshot set not to send email notification.'); $email = 'none'; } $additionalParams = array('ibpass' => '', 'email' => $email, 'stash_copy' => true, 'trim' => backupbuddy_live::get_archive_limit_settings_array(false)); if ('' != pb_backupbuddy::$options['importbuddy_pass_hash']) { $additionalParams['ibpass'] = pb_backupbuddy::$options['importbuddy_pass_hash']; } if (false !== ($timezone = self::tz_offset_to_name(get_option('gmt_offset')))) { $additionalParams['timezone'] = $timezone; } require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php'; $response = pb_backupbuddy_destination_live::stashAPI($destination_settings, 'live-snapshot', $additionalParams, $blocking = true, $passthru_errors = true); self::$_state['stats']['last_remote_snapshot_trigger'] = $trigger; self::$_state['stats']['last_remote_snapshot_response'] = $response; self::$_state['stats']['last_remote_snapshot_response_time'] = microtime(true); self::$_state['stats']['manual_snapshot'] = false; // Set false no matter what. if (pb_backupbuddy::$options['log_level'] == '3') { // Full logging enabled. pb_backupbuddy::status('details', 'live-snapshot response due to logging level: `' . print_r($response, true) . '`. Call params: `' . print_r($additionalParams, true) . ' `.'); } do_action('backupbuddy_run_remote_snapshot_response', $response); return $response; }
echo json_encode($stats); // If there is more to do and too long of time has passed since activity then try to jumpstart the process at the beginning. if ((0 == $stats['files_total'] || $stats['files_sent'] < $stats['files_total']) && 'wait_on_transfers' != $stats['current_function']) { // ( Files to send not yet calculated OR more remain to send ) AND not on the wait_on_transfers step. $time_since_last_activity = microtime(true) - $stats['last_periodic_activity']; if ($time_since_last_activity < 30) { // Don't even bother getting max execution time if it's been less than 30 seconds since run. // do nothing } else { // More than 30 seconds since last activity. // Detect max PHP execution time. If TESTED value is higher than PHP value then go with that since we want to err on not overlapping processes here. $detected_execution = backupbuddy_core::detectLikelyHighestExecutionTime(); if ($time_since_last_activity > $detected_execution + backupbuddy_constants::TIMED_OUT_PROCESS_RESUME_WIGGLE_ROOM) { // Enough time has passed to assume timed out. require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; if (false === ($liveID = backupbuddy_live::getLiveID())) { die('-1'); } if ('1' != pb_backupbuddy::$options['remote_destinations'][$liveID]['pause_periodic']) { // Only proceed if NOT paused. pb_backupbuddy::status('warning', 'BackupBuddy Stash Live process appears timed out while user it viewing Live page. Forcing run now.'); $cronArgs = array(); $schedule_result = backupbuddy_core::schedule_single_event(time(), 'live_periodic', $cronArgs); if (true === $schedule_result) { pb_backupbuddy::status('details', 'Next Live Periodic chunk step cron event scheduled.'); } else { pb_backupbuddy::status('error', 'Next Live Periodic chunk step cron event FAILED to be scheduled.'); } if ('1' != pb_backupbuddy::$options['skip_spawn_cron_call']) { pb_backupbuddy::status('details', 'Spawning cron now.'); update_option('_transient_doing_cron', 0);