public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); if (true !== backupbuddy_api::addSchedule($arguments['title'], $arguments['profile'], $arguments['interval'], $arguments['firstRun'], $arguments['destinations'], $arguments['deleteAfter'], $arguments['enabled'])) { return array('api' => '0', 'status' => 'error', 'message' => 'Error #378235: Creating schedule failed. A plugin may have blocked scheduling with WordPress. Details: ' . backupbuddy_api::$lastError); } else { return array('api' => '0', 'status' => 'ok', 'message' => 'Schedule added successfully.', 'scheduleID' => (int) (pb_backupbuddy::$options['next_schedule_index'] - 1)); } }
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()); } }
public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); $results = backupbuddy_api::runBackup($arguments['profile'], 'iThemes Sync', $backupMode = '2'); if (true !== $results) { return array('api' => '0', 'status' => 'error', 'message' => 'Error running backup. Details: ' . $results); } else { return array('api' => '0', 'status' => 'ok', 'message' => 'Backup initiated successfully.', 'serial' => $serial); } }
public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); $result = backupbuddy_api::deleteSchedule($arguments['id'], $confirm = true); if (true !== $result) { return array('api' => '0', 'status' => 'error', 'message' => 'Error #32893: Failure deleting schedule.'); } else { return array('api' => '0', 'status' => 'ok', 'message' => 'Schedule deleted.'); } }
public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); $status = 'error'; $schedules = backupbuddy_api::getSchedules(); if (false !== $schedules) { $status = 'ok'; } return array('api' => '0', 'status' => $status, 'message' => 'Schedules listed successfully.', 'schedules' => $schedules); }
public function run($arguments = array()) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); if (true === backupbuddy_api::runLiveSnapshot()) { $status = 'ok'; $message = 'Snapshot initiated. Scanning for changes first.'; } else { $status = 'error'; $message = 'Snapshot failed to initiate. A scan is currently in progress.'; } return array('version' => '1', 'status' => $status, 'message' => $message); }
public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); if (!class_exists('backupbuddy_core')) { require_once pb_backupbuddy::plugin_path() . '/classes/core.php'; } $overview = backupbuddy_api::getOverview(); // If archive file is set but actual file does not exist then clear out value. if (isset($overview['lastBackupStats']['archiveFile']) && !file_exists($overview['lastBackupStats']['archiveFile'])) { $overview['lastBackupStats']['archiveFile'] = ''; } return array('version' => '5', 'status' => 'ok', 'message' => 'Overview retrieved successfully.', 'overview' => $overview); }
/** * Run a BackupBuddy backup. http://getbackupbuddy.com * * ## OPTIONS * * <profile> * : Profile may either specify the profile ID number, "full" to run the first defined Full backup profile, or "db" to run the first defined Database-only backup profile. The first Full and Database-only profiles are always available as they are not user-deletable. To find the profile number, run a backup inside BackupBuddy in WordPress and note the number at the end of the URL (3 in this case): http://...&backupbuddy_backup=3 * * [--quiet] * : Suppresses display of status log information from being output to the screen. * * ## EXAMPLES * * RUN FULL BACKUP: wp backupbuddy backup full * RUN PROFILE #3: wp backupbuddy backup 3 * * ## USAGE * * wp backupbuddy backup <profile> [--quiet] * * @synopsis <profile> [--quiet] */ public function backup($args, $assoc_args) { if (!isset($assoc_args['quiet'])) { define('BACKUPBUDDY_WP_CLI', true); } $profile = $args[0]; $results = backupbuddy_api::runBackup($profile, $friendlyTrigger = 'wp-cli', $backupMode = '1'); if (true === $results) { // success WP_CLI::success('Backup completed successfully.'); return; } else { // fail WP_CLI::error('Error initiating backup. Details: ' . $results); } }
if ($result['meta_key'] == '_wp_attachment_metadata') { $data = unserialize($result['file']); foreach ($data['sizes'] as $size) { // Go through each sized thumbnail file. $mediaFiles[$size['file']] = array('modified' => $mediaFiles[$data['file']]['modified']); } } } } // end foreach $results. unset($results); return $mediaFiles; } // End backupbuddy_dbMediaSince(). // Get list of active plugins and remove BackupBuddy from it so we don't update any BackupBuddy files when deploying. Could cause issues with the API replacing files mid-deploy. $activePlugins = backupbuddy_api::getActivePlugins(); foreach ($activePlugins as $activePluginIndex => $activePlugin) { if (false !== strpos($activePlugin['name'], 'BackupBuddy')) { unset($activePlugins[$activePluginIndex]); } } $activePluginDirs = array(); foreach ($activePlugins as $activePluginDir => $activePlugin) { $activePluginDirs[] = dirname(WP_PLUGIN_DIR . '/' . $activePluginDir); } $allPluginDirs = glob(WP_PLUGIN_DIR . '/*', GLOB_ONLYDIR); $inactivePluginDirs = array_diff($allPluginDirs, $activePluginDirs); // Remove active plugins from directories of all plugins to get directories of inactive plugins to exclude later. $inactivePluginDirs[] = pb_backupbuddy::plugin_path(); // Also exclude BackupBuddy directory. // Calculate media files signatures.
public static function runVerb($verb) { if ('getPreDeployInfo' == $verb) { self::apiReturn(backupbuddy_api::getPreDeployInfo()); } }
public static function files_init($state = array()) { $start_time = time(true); $state = array_merge(array('current_step' => 'media', 'step_start' => time(), 'sha1' => false), $state); /* STEPS * 1. Generate list of files, leaving stats blank. * 2. Loop through list. Skip anything set to delete. If scantime is too old, calculate filesize, mtime, and optional sha1. Compare with existing values & update them. If they changed then mark sent to false. * * array[filename] => { * size * mtime * sha1 * scantime * [sent] * [delete] * } * */ /***** MEDIA *****/ if ('1' != pb_backupbuddy::$options['live']['scan_media']) { pb_backupbuddy::status('details', 'Scanning media files disabled based on settings.'); } else { $upload_dir = wp_upload_dir(); $mediaExcludes = array('/backupbuddy_backups', '/pb_backupbuddy', '/backupbuddy_temp'); $mediaExcludes = array_merge($mediaExcludes, self::_getOption('media_excludes', true)); $scandir = $upload_dir['basedir']; pb_backupbuddy::status('details', 'Scanning directory `' . $scandir . '`.'); $mediaSignatures = backupbuddy_core::hashGlob($scandir, $state['sha1'], $mediaExcludes); self::_processSignatures($type = 'media', $mediaSignatures); unset($mediaSignatures); pb_backupbuddy::status('details', 'Time elapsed since files_init: `' . (time() - $start_time) . '` secs.'); } /***** THEMES & CHILDTHEMES *****/ if ('1' != pb_backupbuddy::$options['live']['scan_themes']) { pb_backupbuddy::status('details', 'Scanning theme files disabled based on settings.'); } else { $themeExcludes = self::_getOption('theme_excludes', true); $scandir = get_theme_root(); pb_backupbuddy::status('details', 'Scanning directory `' . $scandir . '`.'); $themeSignatures = backupbuddy_core::hashGlob($scandir, $state['sha1'], $themeExcludes); self::_processSignatures($type = 'theme', $themeSignatures); unset($themeSignatures); pb_backupbuddy::status('details', 'Time elapsed since files_init: `' . (time() - $start_time) . '` secs.'); } /***** CHILDTHEME *****/ /* $childThemeExcludes = self::_getOption( pb_backupbuddy::$options['live']['childtheme_excludes'] ); if ( get_stylesheet_directory() == get_template_directory() ) { // Theme & childtheme are same so do not send any childtheme files! $childThemeSignatures = array(); } else { $childThemeSignatures = backupbuddy_core::hashGlob( get_stylesheet_directory(), $sha1, $childThemeExcludes ); } self::_processSignatures( $type = 'childtheme', $childThemeSignatures ); unset( $childThemeSignatures ); pb_backupbuddy::status( 'details', 'Time elapsed since files_init: `' . ( time() - $start_time ) . '` secs.' ); */ /***** PLUGIN *****/ if ('1' != pb_backupbuddy::$options['live']['scan_plugins']) { pb_backupbuddy::status('details', 'Scanning plugin files disabled based on settings.'); } else { $activePlugins = backupbuddy_api::getActivePlugins(); foreach ($activePlugins as $activePluginIndex => $activePlugin) { if (false !== strpos($activePlugin['name'], 'BackupBuddy')) { unset($activePlugins[$activePluginIndex]); } } $activePluginDirs = array(); foreach ($activePlugins as $activePluginDir => $activePlugin) { $activePluginDirs[] = dirname(WP_PLUGIN_DIR . '/' . $activePluginDir); } $allPluginDirs = glob(WP_PLUGIN_DIR . '/*', GLOB_ONLYDIR); $inactivePluginDirs = array_diff($allPluginDirs, $activePluginDirs); // Remove active plugins from directories of all plugins to get directories of inactive plugins to exclude later. $pluginExcludes = array_merge($inactivePluginDirs, self::_getOption('plugin_excludes', true)); $scandir = WP_PLUGIN_DIR; pb_backupbuddy::status('details', 'Scanning directory `' . $scandir . '`.'); $pluginSignatures = backupbuddy_core::hashGlob($scandir, $state['sha1'], $pluginExcludes); self::_processSignatures($type = 'plugins', $pluginSignatures); unset($pluginSignatures); pb_backupbuddy::status('details', 'Time elapsed since files_init: `' . (time() - $start_time) . '` secs.'); } /***** CUSTOM *****/ if ('1' != pb_backupbuddy::$options['live']['scan_custom']) { pb_backupbuddy::status('details', 'Scanning custom additional directories disabled based on settings.'); } else { $customIncludes = self::_getOption('custom_includes', true); $customSignatures = array(); $abspath_len = strlen(ABSPATH); foreach ($customIncludes as $customInclude) { if ('' == $customInclude || substr($customInclude, 0, $abspath_len) !== ABSPATH) { // Not within ABSPATH. continue; } pb_backupbuddy::status('details', 'Scanning directory `' . $customInclude . '`.'); $customSignatures = array_merge($customSignatures, backupbuddy_core::hashGlob($customInclude, $state['sha1'])); } self::_processSignatures($type = 'custom', $customSignatures); unset($customSignatures); pb_backupbuddy::status('details', 'Time elapsed since files_init: `' . (time() - $start_time) . '` secs.'); } echo 'Total time: ' . (time() - $start_time); }
/** * Sets the status in the plugin dashboard * * Sets a medium priority item for the module's functionality in the plugin * dashboard. * * @since 4.0.0 * * @param array $statuses array of existing plugin dashboard statuses * * @return array statuses */ public function itsec_add_dashboard_status($statuses) { if (!is_multisite() && class_exists('backupbuddy_api') && 1 <= sizeof(backupbuddy_api::getSchedules())) { if (true === $this->settings['enabled']) { //disable our backups if we have to $this->settings['enabled'] = false; update_site_option('itsec_backup', $this->settings); } $status_array = 'safe-medium'; $status = array('text' => __('Your site is performing scheduled database and file backups.', 'it-l10n-ithemes-security-pro'), 'link' => '?page=pb_backupbuddy_scheduling'); } elseif (!is_multisite() && class_exists('backupbuddy_api')) { if ($this->settings['enabled'] === true) { //disable our backups if we have to $this->settings['enabled'] = false; update_site_option('itsec_backup', $this->settings); } $status_array = 'medium'; $status = array('text' => __('BackupBuddy is installed but backups do not appear to have been scheduled. Please schedule backups.', 'it-l10n-ithemes-security-pro'), 'link' => '?page=pb_backupbuddy_scheduling'); } elseif (true === $this->has_backup() && true === $this->scheduled_backup()) { if (true === $this->settings['enabled']) { //disable our backups if we have to $this->settings['enabled'] = false; update_site_option('itsec_backup', $this->settings); } $status_array = 'safe-medium'; $status = array('text' => __('You are using a 3rd party backup solution.', 'it-l10n-ithemes-security-pro'), 'link' => $this->external_backup_link()); } elseif (true === $this->has_backup()) { if (true === $this->settings['enabled']) { //disable our backups if we have to $this->settings['enabled'] = false; update_site_option('itsec_backup', $this->settings); } $status_array = 'medium'; $status = array('text' => __('It looks like you have a 3rd-party backup solution in place but are not using it. Please turn on scheduled backups.', 'it-l10n-ithemes-security-pro'), 'link' => $this->external_backup_link()); } elseif (true === $this->settings['enabled']) { $status_array = 'medium'; $status = array('text' => __('Your site is performing scheduled database backups but is not backing up files. Consider purchasing or scheduling BackupBuddy to protect your investment.', 'it-l10n-ithemes-security-pro'), 'link' => 'http://ithemes.com/better-backups'); } else { $status_array = 'high'; $status = array('text' => __('Your site is not performing any scheduled database backups.', 'it-l10n-ithemes-security-pro'), 'link' => '#itsec_backup_enabled'); } array_push($statuses[$status_array], $status); return $statuses; }
$error = true; } $remote_destinations = trim($submitted_schedule['data']['remote_destinations'], '|'); $remote_destinations = explode('|', $remote_destinations); if ('1' == $submitted_schedule['data']['delete_after']) { $delete_after = true; } else { $delete_after = false; } if ('1' == $submitted_schedule['data']['on_off']) { $enabled = true; } else { $enabled = false; } if ($error === false) { $add_response = backupbuddy_api::addSchedule($title = $submitted_schedule['data']['title'], $profile = $submitted_schedule['data']['profile'], $interval = $submitted_schedule['data']['interval'], $first_run = pb_backupbuddy::$format->unlocalize_time(strtotime($submitted_schedule['data']['first_run'])), $remote_destinations, $delete_after, $enabled); if (true !== $add_response) { pb_backupbuddy::alert('Error scheduling: ' . $add_response); } else { // Success pb_backupbuddy::save(); $schedule_form->clear_values(); pb_backupbuddy::alert('Added new schedule `' . htmlentities($submitted_schedule['data']['title']) . '`.'); } } } else { // EDIT SCHEDULE. Form handles saving; just need to update timestamp. $first_run = pb_backupbuddy::$format->unlocalize_time(strtotime($submitted_schedule['data']['first_run'])); if ($first_run == 0 || $first_run == 18000) { pb_backupbuddy::alert(sprintf(__('Invalid time format. Please use the specified format / example %s', 'it-l10n-backupbuddy'), $date_format_example)); $error = true;
function backup_status() { $status = 0; if (!is_multisite() && class_exists('backupbuddy_api') && count(backupbuddy_api::getSchedules()) >= 1) { $status = 1; } elseif (!is_multisite() && class_exists('backupbuddy_api')) { $status = 2; } elseif ($this->has_backup() === true && $this->scheduled_backup() === true) { $status = 3; } elseif ($this->has_backup() === true) { $status = 4; } return $status; }
if (null === $results || false === $results) { pb_backupbuddy::status('error', 'Error #238933: Unable to calculate media with query `' . $sql . '`. Check database permissions or contact host.'); } foreach ((array) $results as $result) { if ($result['meta_key'] == '_wp_attached_file') { $mediaFiles[$result['file']] = array('modified' => $result['file_modified']); } if (true === $includeThumbs) { if ($result['meta_key'] == '_wp_attachment_metadata') { $data = unserialize($result['file']); foreach ($data['sizes'] as $size) { $mediaFiles[$size['file']] = array('modified' => $mediaFiles[$data['file']]['modified']); } } } } unset($results); return $mediaFiles; } $upload_dir = wp_upload_dir(); $excludes = array('/backupbuddy_backups', '/pb_backupbuddy', '/backupbuddy_temp'); $mediaSignatures = backupbuddy_hashGlob($upload_dir['basedir'], $sha = false, $excludes); //backupbuddy_dbMediaSince( $includeThumbs = true ); /* echo '<pre>'; print_r( $mediaSignatures ); echo '</pre>'; */ global $wp_version; return array('backupbuddyVersion' => pb_backupbuddy::settings('version'), 'wordpressVersion' => $wp_version, 'localTime' => time(), 'php' => array('upload_max_filesize' => $upload_max_filesize, 'max_execution_time' => $max_execution_time, 'memory_limit' => $memory_limit, 'max_post_size' => $max_post_size), 'abspath' => ABSPATH, 'siteurl' => site_url(), 'homeurl' => home_url(), 'tables' => $dbTables, 'dbPrefix' => $wpdb->prefix, 'activePlugins' => backupbuddy_api::getActivePlugins(), 'activeTheme' => get_template(), 'themeSignatures' => backupbuddy_hashGlob(get_template_directory()), 'mediaSignatures' => $mediaSignatures, 'mediaCount' => count($mediaSignatures), 'notifications' => array()); unset($mediaSignatures);
$memory_limit = 32; } $root = get_template_directory(); $generate_sha1 = true; //echo 'mem:' . memory_get_usage(true) . '<br>'; $files = (array) pb_backupbuddy::$filesystem->deepglob($root); //echo 'mem:' . memory_get_usage(true) . '<br>'; $root_len = strlen($root); $hashedFiles = array(); foreach ($files as $file_id => &$file) { $stat = stat($file); if (FALSE === $stat) { pb_backupbuddy::status('error', 'Unable to read file `' . $file . '` stat.'); } $new_file = substr($file, $root_len); $sha1 = ''; if (true === $generate_sha1 && $stat['size'] < 1073741824) { // < 100mb $sha1 = sha1_file($file); } $hashedFiles[$new_file] = array('size' => $stat['size'], 'modified' => $stat['mtime'], 'sha1' => $sha1); unset($files[$file_id]); // Better to free memory or leave out for performance? } unset($files); //echo 'mem:' . memory_get_usage(true) . '<br>'; //echo 'filecount: ' . count( $new_files ) . '<br>'; //print_r( $new_files ); global $wp_version; return array('backupbuddyVersion' => pb_backupbuddy::settings('version'), 'wordpressVersion' => $wp_version, 'localTime' => time(), 'php' => array('upload_max_filesize' => $upload_max_filesize, 'max_execution_time' => $max_execution_time, 'memory_limit' => $memory_limit), 'abspath' => ABSPATH, 'siteurl' => site_url(), 'homeurl' => home_url(), 'activePlugins' => backupbuddy_api::getActivePlugins(), 'activeTheme' => get_template(), 'themeSignatures' => $hashedFiles, 'notifications' => array());
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'); ?>
$add_response = backupbuddy_api::addSchedule($title, $profile = '2', $interval = 'monthly', $first_run = time() + get_option('gmt_offset') * 3600 + 86400 + 18000, $remote_destinations = array($destination_id)); if (true !== $add_response) { $errors[] = $add_response; } } } // BLOGGER if ('blogger' == $form['schedule']) { $title = 'Daily Database (Quick Setup - Blogger)'; if (false === pb_backupbuddy_schedule_exist_by_title($title)) { $add_response = backupbuddy_api::addSchedule($title, $profile = '1', $interval = 'daily', $first_run = time() + get_option('gmt_offset') * 3600 + 86400, $remote_destinations = array($destination_id)); if (true !== $add_response) { $errors[] = $add_response; } } $title = 'Weekly Full (Quick Setup - Blogger)'; if (false === pb_backupbuddy_schedule_exist_by_title($title)) { $add_response = backupbuddy_api::addSchedule($title, $profile = '2', $interval = 'weekly', $first_run = time() + get_option('gmt_offset') * 3600 + 86400 + 18000, $remote_destinations = array($destination_id)); if (true !== $add_response) { $errors[] = $add_response; } } } } // end set schedule. if (0 == count($errors)) { pb_backupbuddy::save(); die('Success.'); } else { die(implode("\n", $errors)); }
<?php if (!is_admin()) { die('Access denied.'); } // IMPORTANT: MUST provide 3rd param, backup serial ID, when using pb_backupbuddy::status() within this function for it to show for this backup. $serial = trim(pb_backupbuddy::_POST('serial')); $serial = str_replace('/\\', '', $serial); $initRetryCount = (int) trim(pb_backupbuddy::_POST('initwaitretrycount')); $specialAction = pb_backupbuddy::_POST('specialAction'); $sqlFile = pb_backupbuddy::_POST('sqlFile'); backupbuddy_api::getBackupStatus($serial, $specialAction, $initRetryCount, $sqlFile, $echo = true); die;
public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); backupbuddy_api::getBackupStatus($arguments['serial']); return; }
public function run($arguments = array()) { $stats = backupbuddy_api::getLiveStats(); return array('version' => '1', 'status' => 'ok', 'message' => 'Live stats retrieved successfully.', 'stats' => $stats); }
window.location.href = '<?php echo pb_backupbuddy::ajax_url('deploy'); ?> &step=run&deployment=<?php echo $destination_id; ?> &backup_profile=' + jQuery( '#deploy_profile_selected' ).val(); return false; }); */ }); </script> <?php $localInfo = backupbuddy_api::getPreDeployInfo(); $status = $deploy->start($localInfo); $errorMessage = ''; if (false === $status) { $errors = $deploy->getErrors(); if (count($errors) > 0) { $errorMessage = 'Errors were encountered: ' . implode(', ', $errors) . ' <b><i>If seeking support please provide the details above.</i></b>'; } $siteUp = false; } else { $siteUp = true; } ?> <table class="widefat deploy-sites-table"> <tr>
public function run($arguments = array()) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); $status = backupbuddy_api::setLiveStatus($arguments['pause_continuous'], $arguments['pause_periodic'], $arguments['start_run']); return array('version' => '1', 'status' => 'ok', 'message' => 'Live status updated successfully.', 'status' => $status); }
if (!is_numeric($first_run)) { backupbuddy_api::$lastError = 'Error #238983: First run time must be numeric.'; return false; } if (!is_array($remote_destinations)) { $remote_destinations = array(); } if (!(bool) $delete_after) { $delete_after = false; } if (!(bool) $enabled) { $enabled = false; } if (!isset(pb_backupbuddy::$options['profiles'][$profile])) { backupbuddy_api::$lastError = 'Error #378646: Invalid profile ID.'; return false; } $schedule = pb_backupbuddy::settings('schedule_defaults'); $schedule['title'] = $title; $schedule['profile'] = (int) $profile; $schedule['interval'] = $interval; $schedule['first_run'] = $first_run; $schedule['remote_destinations'] = implode('|', $remote_destinations); if (true == $delete_after) { $schedule['delete_after'] = '1'; } else { $schedule['delete_after'] = '0'; } if (false == $enabled) { $schedule['on_off'] = '0';
function stats() { $getOverview = backupbuddy_api::getOverview(); $backup_url = 'admin.php?page=pb_backupbuddy_backup'; // Red-Green status for editsSinceLastBackup if ($getOverview['editsSinceLastBackup'] == 0) { $status = 'green'; } else { $status = 'red'; } // Format file archiveSize to readable format if (isset($getOverview['lastBackupStats']['archiveSize']) && is_numeric($getOverview['lastBackupStats']['archiveSize'])) { $file_size = $getOverview['lastBackupStats']['archiveSize']; if ($file_size >= 1073741824) { $archiveSize = round($file_size / 1024 / 1024 / 1024, 2) . ' GB'; } elseif ($file_size >= 1048576) { $archiveSize = round($file_size / 1024 / 1024, 1) . ' MB'; } elseif ($file_size >= 1024) { $archiveSize = round($file_size / 1024, 0) . ' KB'; } else { $archiveSize = $file_size . ' bytes'; } } else { $archiveSize = 'Unknown'; } // Format timestamp if (isset($getOverview['lastBackupStats']['finish'])) { $time = pb_backupbuddy::$format->localize_time($getOverview['lastBackupStats']['finish']); $time_nice = date("M j - g:i A", $time); } else { $time_nice = 'Unknown'; } // Format Type if (isset($getOverview['lastBackupStats']['type'])) { if ($getOverview['lastBackupStats']['type'] == 'full') { $backup_type = 'Full'; } elseif ($getOverview['lastBackupStats']['type'] == 'db') { $backup_type = 'Database'; } else { $backup_type = $getOverview['lastBackupStats']['type']; } } else { $backup_type = 'Unknown'; } // Build widget markup ob_start(); ?> <div class="edits-since-wrapper"> <p class="edits-since <?php echo $status; ?> "> <?php echo $getOverview['editsSinceLastBackup']; ?> </p> <h4 class="number-heading">Edits since<br>last Backup</h4> </div> <?php if (isset($getOverview['lastBackupStats']['finish'])) { // only show if a last backup exists. ?> <div class="info-group"> <h3>Latest Backup</h3> <ul class="backup-list"> <li> <div class="list-wrapper"> <div class="list-title"> <a href="<?php if (isset($getOverview['lastBackupStats']['archiveURL'])) { echo $getOverview['lastBackupStats']['archiveURL']; } ?> "><?php _e('Download', 'it-l10n-backupbuddy'); ?> </a> </div> <div class="list-description"> <div class="backup-type description-item"> <span>Type</span><br> <?php echo $backup_type; ?> </div> <div class="backup-size description-item"> <span>Size</span><br> <?php echo $archiveSize; ?> </div> <div class="backup-time description-item"> <span>Time</span><br> <?php echo $time_nice; ?> </div> </div> </div> </li> </ul> </div> <?php } ?> <div class="backup-now"> <a href="<?php echo $backup_url; ?> "><?php _e('Backup Now', 'it-l10n-backupbuddy'); ?> </a> </div> <?php ob_end_flush(); }
private static function _test_live_state() { self::$_results['live_stats'] = backupbuddy_api::getLiveStats(); }
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) . '`.'); }
private static function _verb_getPreDeployInfo() { die(json_encode(array('success' => true, 'data' => backupbuddy_api::getPreDeployInfo()))); }
<?php backupbuddy_core::verifyAjaxAccess(); // Check if running PHP 5.3+. $php_minimum = 5.3; if (version_compare(PHP_VERSION, $php_minimum, '<')) { // Server's PHP is insufficient. die('-1'); } if (false === ($stats = backupbuddy_api::getLiveStats())) { // Live is disconnected. die('-1'); } 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'); }