function process_backup($serial = 'blank') { pb_backupbuddy::set_status_serial($serial); pb_backupbuddy::status('details', '--- New PHP process.'); pb_backupbuddy::set_greedy_script_limits(); pb_backupbuddy::status('message', 'Running process for serial `' . $serial . '`...'); require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); $newBackup->process_backup($serial); }
function process_scheduled_backup($cron_id) { if (!class_exists('backupbuddy_core')) { require_once pb_backupbuddy::plugin_path() . '/classes/core.php'; } if (!isset(pb_backupbuddy::$options)) { $this->load(); } // Verify directories. backupbuddy_core::verify_directories($skipTempGeneration = true); pb_backupbuddy::status('details', 'cron_process_scheduled_backup: ' . $cron_id); $preflight_message = ''; $preflight_checks = backupbuddy_core::preflight_check(); foreach ($preflight_checks as $preflight_check) { if ($preflight_check['success'] !== true) { pb_backupbuddy::status('warning', $preflight_check['message']); } } if (isset(pb_backupbuddy::$options['schedules'][$cron_id]) && is_array(pb_backupbuddy::$options['schedules'][$cron_id])) { // If schedule is disabled then just return. Bail out! if (isset(pb_backupbuddy::$options['schedules'][$cron_id]['on_off']) && pb_backupbuddy::$options['schedules'][$cron_id]['on_off'] == '0') { pb_backupbuddy::status('message', 'Schedule `' . $cron_id . '` NOT run due to being disabled based on this schedule\'s settings.'); return; } pb_backupbuddy::$options['schedules'][$cron_id]['last_run'] = time(); // update last run time. pb_backupbuddy::save(); require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); if (pb_backupbuddy::$options['schedules'][$cron_id]['delete_after'] == '1') { $delete_after = true; pb_backupbuddy::status('details', 'Option to delete file after successful transfer enabled.'); } else { $delete_after = false; pb_backupbuddy::status('details', 'Option to delete file after successful transfer disabled.'); } // If any remote destinations are set then add these to the steps to perform after the backup. $post_backup_steps = array(); $destinations = explode('|', pb_backupbuddy::$options['schedules'][$cron_id]['remote_destinations']); $found_valid_destination = false; // Remove any invalid destinations from this run. foreach ($destinations as $destination_index => $destination) { if (!isset($destination) || $destination == '') { // Remove. unset($destinations[$destination_index]); } if (!isset(pb_backupbuddy::$options['remote_destinations'][$destination])) { // Destination ID is invalid; remove. unset($destinations[$destination_index]); } } $destination_count = count($destinations); $i = 0; foreach ($destinations as $destination) { $i++; if ($i >= $destination_count) { // Last destination. Delete after if enabled. $this_delete_after = $delete_after; pb_backupbuddy::status('details', 'Last destination set to send to so this file deletion will be determined by settings.'); } else { // More destinations to send to. Only delete after final send. $this_delete_after = false; pb_backupbuddy::status('details', 'More destinations are set to send to so this file will not be deleted after send.'); } $args = array($destination, $this_delete_after); pb_backupbuddy::status('details', 'Adding send step with args `' . implode(',', $args) . '`.'); array_push($post_backup_steps, array('function' => 'send_remote_destination', 'args' => $args, 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0)); $found_valid_destination = true; pb_backupbuddy::status('details', 'Found valid destination.'); } $profile_array = pb_backupbuddy::$options['profiles'][pb_backupbuddy::$options['schedules'][$cron_id]['profile']]; if ($newBackup->start_backup_process($profile_array, 'scheduled', array(), $post_backup_steps, pb_backupbuddy::$options['schedules'][$cron_id]['title']) !== true) { pb_backupbuddy::status('error', 'Error #4564658344443: Backup failure. See earlier logging details for more information.'); } } pb_backupbuddy::status('details', 'Finished cron_process_scheduled_backup.'); }
<?php pb_backupbuddy::load_style('backupProcess.css'); pb_backupbuddy::load_style('backupProcess2.css'); wp_enqueue_script('thickbox'); wp_print_scripts('thickbox'); wp_print_styles('thickbox'); // 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'); } require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); $serial_override = pb_backupbuddy::random_string(10); // Set serial ahead of time so can be used by AJAX before backup procedure actually begins. // Deploy direction. if ('push' == pb_backupbuddy::_GET('direction')) { $direction = 'push'; $direction_text = ' - ' . __('Push', 'it-l10n-backupbuddy'); } elseif ('pull' == pb_backupbuddy::_GET('direction')) { $direction = 'pull'; $direction_text = ' - ' . __('Pull', 'it-l10n-backupbuddy'); } else { $direction = ''; $direction_text = ''; } // Title for page. if ('deploy' == pb_backupbuddy::_GET('backupbuddy_backup')) { pb_backupbuddy::$ui->title('Deploy Site' . $direction_text); } else {
} else { $profile = $generic_type_or_profile_id_or_array; if ('db' == $profile) { // db profile is always index 1. $profile = '1'; } elseif ('full' == $profile) { // full profile is always index 2. $profile = '2'; } if (is_numeric($profile)) { if (isset(pb_backupbuddy::$options['profiles'][$profile])) { $profileArray = pb_backupbuddy::$options['profiles'][$profile]; } else { return 'Error #2332904: Invalid profile ID `' . htmlentities($profile) . '`. Profile with this number was not found. Try deactivating then reactivating the plugin. If this fails please reset the plugin Settings back to Defaults from the Settings page.'; } } else { return 'Error #85489548955. You cannot refresh this page to re-run it to prevent accidents. You will need to go back and try again. (Invalid profile ID not numeric: `' . htmlentities($profile) . '`).'; } } $profileArray['backup_mode'] = $backupMode; // Force modern mode when running under API. 1=classic (single page load), 2=modern (cron) if ('' == $backupSerial) { $backupSerial = pb_backupbuddy::random_string(10); } require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); // Run the backup! if ($newBackup->start_backup_process($profileArray, $triggerTitle, array(), array(), $triggerTitle, $backupSerial, array()) !== true) { return 'Error #435832: Backup failed. See BackupBuddy log for details.'; } return true;