Esempio n. 1
0
 public function backup_status()
 {
     // Make sure the serial exists.
     if (pb_backupbuddy::_POST('serial') == '' || empty(pb_backupbuddy::$options['backups'][$_POST['serial']])) {
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|error|~|Error #5445589. Invalid backup serial (' . htmlentities(pb_backupbuddy::_POST('serial')) . '). Please check directory permissions and your PHP error_log as an early backup function (such as pre_backup) may have failed. Fatal error.' . "\n";
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|halt_script' . "\n";
     } else {
         // Return the status information since last retrieval.
         $return_status = '!' . pb_backupbuddy::$format->localize_time(time()) . "|~|0|~|0|~|ping\n";
         //error_log( print_r( pb_backupbuddy::$options['backups'], true ) );
         foreach (pb_backupbuddy::$options['backups'][$_POST['serial']]['steps'] as $step) {
             if ($step['start_time'] != 0 && $step['finish_time'] == 0) {
                 // A step has begun but has not finished. This should not happen but the WP cron is funky. Wait a while before continuing.
                 pb_backupbuddy::status('details', 'Waiting for function `' . $step['function'] . '` to complete. Started ' . (time() - $step['start_time']) . ' seconds ago.', $_POST['serial']);
                 if (time() - $step['start_time'] > 300) {
                     pb_backupbuddy::status('warning', 'The function `' . $step['function'] . '` is taking an abnormally long time to complete (' . (time() - $step['start_time']) . ' seconds). The backup may have stalled.', $_POST['serial']);
                 }
             } elseif ($step['start_time'] == 0) {
                 // Step that has not started yet.
             } else {
                 // Last case: Finished. Skip.
                 // Do nothing.
             }
         }
         /********** Begin file sizes for status updates. *********/
         $temporary_zip_directory = pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . $_POST['serial'] . '/';
         if (file_exists($temporary_zip_directory)) {
             // Temp zip file.
             $directory = opendir($temporary_zip_directory);
             while ($file = readdir($directory)) {
                 if ($file != '.' && $file != '..') {
                     $stats = stat($temporary_zip_directory . $file);
                     $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|details|~|' . __('Temporary ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
                     $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
                 }
             }
             closedir($directory);
             unset($directory);
         }
         if (file_exists(pb_backupbuddy::$options['backups'][$_POST['serial']]['archive_file'])) {
             // Final zip file.
             $stats = stat(pb_backupbuddy::$options['backups'][$_POST['serial']]['archive_file']);
             $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|details|~|' . __('Final ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
             $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
         }
         /********** End file sizes for status updates. *********/
         $status_lines = pb_backupbuddy::get_status(pb_backupbuddy::_POST('serial'), true, false, true);
         // Clear file, dont unlink file (pclzip cant handle files unlinking mid-zip), dont show getting status message.
         if ($status_lines !== false) {
             // Only add lines if there is status contents.
             foreach ($status_lines as $status_line) {
                 //$return_status .= '!' . $status_line[0] . '|' . $status_line[3] . '|' . $status_line[4] . '( ' . $status_line[1] . 'secs / ' . $status_line[2] . 'MB )' . "\n";
                 $return_status .= '!' . implode('|~|', $status_line) . "\n";
             }
         }
         // Return messages.
         echo $return_status;
     }
     die;
 }
Esempio n. 2
0
 function backup_integrity_check($file)
 {
     $serial = $this->get_serial_from_file($file);
     // User selected to rescan a file.
     if (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         pb_backupbuddy::alert('Rescanning backup integrity for backup file `' . basename($file) . '`');
     }
     if (isset(pb_backupbuddy::$options['backups'][$serial]['integrity']) && count(pb_backupbuddy::$options['backups'][$serial]['integrity']) > 0 && pb_backupbuddy::_GET('reset_integrity') != $serial) {
         // Already have integrity data and NOT resetting this one.
         pb_backupbuddy::status('details', 'Integrity data for backup `' . $serial . '` is cached; not scanning again.');
         return;
     } elseif (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         // Resetting this one.
         pb_backupbuddy::status('details', 'Resetting backup integrity stats for backup with serial `' . $serial . '`.');
     }
     if (pb_backupbuddy::$options['integrity_check'] == '0') {
         // Integrity checking disabled.
         $file_stats = @stat($file);
         if ($file_stats === false) {
             // stat failure.
             pb_backupbuddy::alert('Error #4539774. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
             $file_size = 0;
             $file_modified = 0;
         } else {
             // stat success.
             $file_size = $file_stats['size'];
             $file_modified = $file_stats['mtime'];
         }
         unset($file_stats);
         $integrity = array('status' => 'Unknown', 'status_details' => __('Integrity checking disabled based on settings. This file has not been verified.', 'it-l10n-backupbuddy'), 'scan_time' => 0, 'detected_type' => 'unknown', 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => false);
         pb_backupbuddy::$options['backups'][$serial]['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
         pb_backupbuddy::save();
         return;
     }
     // Defaults
     $integrity_checked = true;
     $found_dat = false;
     $found_sql = false;
     $found_wpc = false;
     $backup_type = '';
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(pb_backupbuddy::$options['backup_directory']);
     }
     // Redirect logging output to a certain log file.
     pb_backupbuddy::set_status_serial('zipbuddy_test');
     // Look for comment.
     $comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($file);
     // Check for DAT file.
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/backupbuddy_dat.php') === true) {
         // Post 2.0 full backup
         $found_dat = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/backupbuddy_dat.php') === true) {
         // Pre 2.0 full backup
         $found_dat = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'backupbuddy_dat.php') === true) {
         // DB backup
         $found_dat = true;
         $backup_type = 'db';
     }
     // Check for DB SQL file.
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/db_1.sql') === true) {
         // post 2.0 full backup
         $found_sql = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/db.sql') === true) {
         // pre 2.0 full backup
         $found_sql = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db_1.sql') === true) {
         // db only backup 2.0+
         $found_sql = true;
         $backup_type = 'db';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db.sql') === true) {
         // db only backup pre-2.0
         $found_sql = true;
         $backup_type = 'db';
     }
     // Check for WordPress config file.
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-config.php') === true) {
         $found_wpc = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/wp-config.php') === true) {
         $found_wpc = true;
         $backup_type = 'full';
     }
     // Calculate status from results.
     $integrity_status = 'pass';
     $integrity_description = '';
     $status_items = pb_backupbuddy::get_status('zipbuddy_test');
     $integrity_zipresult_details = array();
     foreach ((array) $status_items as $status_item) {
         $integrity_zipresult_details[] = $status_item[4];
     }
     $integrity_zipresult_details = implode('<br />', $integrity_zipresult_details);
     // Clear logging to certain file.
     pb_backupbuddy::set_status_serial('');
     // Calculate status descriptions.
     if ($found_dat !== true) {
         $integrity_status = 'fail';
         $integrity_description .= __('Missing .dat file.', 'it-l10n-backupbuddy') . '<br />';
     }
     if ($found_sql !== true) {
         $integrity_status = 'fail';
         $integrity_description .= __('Missing DB SQL file.', 'it-l10n-backupbuddy') . '<br />';
     }
     if ($backup_type == 'full' && $found_wpc !== true) {
         $integrity_status = 'fail';
         $integrity_description .= __('Missing WP config file.', 'it-l10n-backupbuddy') . '<br />';
     }
     $integrity_scantime = time();
     if ($integrity_status == 'pass') {
         // All tests passed.
         $integrity_description = 'All tests passed.';
     } else {
         // One or more test failures encountered.
         $integrity_description .= '<br />' . __('Technical Details', 'it-l10n-backupbuddy') . ':<br />' . $integrity_zipresult_details;
     }
     // Get file information from file system.
     $file_stats = @stat($file);
     if ($file_stats === false) {
         // stat failure.
         pb_backupbuddy::alert('Error #4539774. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
         $file_size = 0;
         $file_modified = 0;
     } else {
         // stat success.
         $file_size = $file_stats['size'];
         $file_modified = $file_stats['ctime'];
         // Created time.
     }
     unset($file_stats);
     // Compile array of results for saving into data structure.
     $integrity = array('status' => $integrity_status, 'status_details' => $integrity_description, 'scan_time' => $integrity_scantime, 'detected_type' => $backup_type, 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => $comment);
     pb_backupbuddy::$options['backups'][$serial]['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
     pb_backupbuddy::save();
     //pb_backupbuddy::$classes['zipbuddy']->clear_status();
     if ($integrity_status == 'pass') {
         // 100% success
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 public function backup_status()
 {
     $serial = trim(pb_backupbuddy::_POST('serial'));
     // Make sure the serial exists.
     if ($serial == '' || empty(pb_backupbuddy::$options['backups'][$serial])) {
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|error|~|Error #9031. Invalid backup serial (' . htmlentities($serial) . '). Please check directory permissions for your wp-content/uploads/ directory recursively, your PHP error_log for any errors, and that you have enough free disk space. If seeking support please provide this full status log and PHP error log. Fatal error.' . "\n";
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|halt_script' . "\n";
     } else {
         // Verify init completed.
         if (false === pb_backupbuddy::$options['backups'][$serial]['init_complete']) {
             pb_backupbuddy::status('error', 'Error #9033: The pre-backup initialization did not fully complete. Check for any errors above or in logs. Verify permissions & that there is enough server memory. See the BackupBuddy "Server Information" page to help assess your server.', $serial);
             pb_backupbuddy::status('action', 'halt_script', $serial);
         }
         //***** Begin outputting status of the current step.
         foreach (pb_backupbuddy::$options['backups'][$serial]['steps'] as $step) {
             if ($step['start_time'] != 0 && $step['finish_time'] == 0) {
                 // A step has begun but has not finished. This should not happen but the WP cron is funky. Wait a while before continuing.
                 // For database dump step output the SQL file current size.
                 if ($step['function'] == 'backup_create_database_dump') {
                     $sql_file = pb_backupbuddy::$options['backups'][$serial]['temp_directory'] . 'db_1.sql';
                     if (file_exists($sql_file)) {
                         $sql_filesize = pb_backupbuddy::$format->file_size(filesize($sql_file));
                     } else {
                         // No SQL file yet.
                         $sql_filesize = '[SQL file not found yet]';
                     }
                     pb_backupbuddy::status('details', 'Current SQL database dump file size: ' . $sql_filesize . '.', $serial);
                 }
                 pb_backupbuddy::status('details', 'Waiting for function `' . $step['function'] . '` to complete. Started ' . (time() - $step['start_time']) . ' seconds ago.', $serial);
                 if (time() - $step['start_time'] > 300) {
                     pb_backupbuddy::status('warning', 'The function `' . $step['function'] . '` is taking an abnormally long time to complete (' . (time() - $step['start_time']) . ' seconds). The backup may have stalled.', $serial);
                 }
             } elseif ($step['start_time'] == 0) {
                 // Step that has not started yet.
             } else {
                 // Last case: Finished. Skip.
                 // Do nothing.
             }
         }
         //***** End outputting status of the current step.
         //***** Begin output of temp zip file size.
         $temporary_zip_directory = pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . $serial . '/';
         if (file_exists($temporary_zip_directory)) {
             // Temp zip file.
             $directory = opendir($temporary_zip_directory);
             while ($file = readdir($directory)) {
                 if ($file != '.' && $file != '..' && $file != 'exclusions.txt') {
                     $stats = stat($temporary_zip_directory . $file);
                     //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|details|~|' . __('Temporary ZIP file size', 'it-l10n-backupbuddy' ) .': ' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";;
                     pb_backupbuddy::status('details', __('Temporary ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                     //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";
                     pb_backupbuddy::status('action', 'archive_size^' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                 }
             }
             closedir($directory);
             unset($directory);
         }
         //***** End output of temp zip file size.
         // Output different stuff to the browser depending on whether backup is finished or not.
         if (pb_backupbuddy::$options['backups'][$serial]['finish_time'] > 0) {
             // BACKUP FINISHED.
             // OUTPUT COMPLETED ZIP FINAL SIZE.
             if (file_exists(pb_backupbuddy::$options['backups'][$serial]['archive_file'])) {
                 // Final zip file.
                 $stats = stat(pb_backupbuddy::$options['backups'][$serial]['archive_file']);
                 //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|details|~|' . __('Completed backup final ZIP file size', 'it-l10n-backupbuddy' ) . ': ' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";;
                 pb_backupbuddy::status('details', __('Completed backup final ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                 //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";
                 pb_backupbuddy::status('action', 'archive_size^' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                 $backup_finished = true;
             } else {
                 pb_backupbuddy::status('error', __('Backup reports success but unable to access final ZIP file. Verify permissions and ownership. If the error persists insure that server is properly configured with suphp and proper ownership & permissions.', 'it-l10n-backupbuddy'), $serial);
             }
             pb_backupbuddy::status('message', __('Backup successfully completed in ', 'it-l10n-backupbuddy') . ' ' . pb_backupbuddy::$format->time_duration(pb_backupbuddy::$options['backups'][$serial]['finish_time'] - pb_backupbuddy::$options['backups'][$serial]['start_time']) . '.', $serial);
             pb_backupbuddy::status('action', 'finish_backup', $serial);
         } else {
             // NOT FINISHED
             //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . "|~|0|~|0|~|ping\n";
             pb_backupbuddy::status('message', __('Ping. Waiting for server . . .', 'it-l10n-backupbuddy'), $serial);
         }
         //***** Begin getting status log information.
         $return_status = '';
         $status_lines = pb_backupbuddy::get_status($serial, true, false, true);
         // Clear file, dont unlink file (pclzip cant handle files unlinking mid-zip), dont show getting status message.
         if ($status_lines !== false) {
             // Only add lines if there is status contents.
             foreach ($status_lines as $status_line) {
                 //$return_status .= '!' . $status_line[0] . '|' . $status_line[3] . '|' . $status_line[4] . '( ' . $status_line[1] . 'secs / ' . $status_line[2] . 'MB )' . "\n";
                 $return_status .= '!' . implode('|~|', $status_line) . "\n";
             }
         }
         //***** End getting status log information.
         echo $return_status;
         // Return messages.
     }
     die;
 }
Esempio n. 4
0
 public function backup_status()
 {
     $serial = trim(pb_backupbuddy::_POST('serial'));
     $serial = str_replace('/\\', '', $serial);
     $init_wait_retry_count = (int) trim(pb_backupbuddy::_POST('initwaitretrycount'));
     if (true == get_transient('pb_backupbuddy_stop_backup-' . $serial)) {
         pb_backupbuddy::status('message', 'Backup STOPPED. Post backup cleanup step has been scheduled to clean up any temporary files.', $serial);
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt';
         $backup_options = new pb_backupbuddy_fileoptions($fileoptions_file, false, $ignore_lock = true);
         if (true !== ($result = $backup_options->is_ok())) {
             pb_backupbuddy::status('error', 'Unable to access fileoptions file `' . $fileoptions_file . '`.', $serial);
         }
         // Wipe backup file.
         if (isset($backup_options->options['archive_file']) && file_exists($backup_options->options['archive_file'])) {
             // Final zip file.
             $unlink_result = @unlink($backup_options->options['archive_file']);
             if (true === $unlink_result) {
                 pb_backupbuddy::status('details', 'Deleted stopped backup ZIP file.', $serial);
             } else {
                 pb_backupbuddy::status('error', 'Unable to delete stopped backup file. You should delete it manually as it may be damaged from stopping mid-backup. File to delete: `' . $backup_options->options['archive_file'] . '`.', $serial);
             }
         } else {
             pb_backupbuddy::status('details', 'Archive file not found. Not deleting.', $serial);
         }
         // NOTE: fileoptions file will be wiped by periodic cleanup. We need to keep this for now...
         delete_transient('pb_backupbuddy_stop_backup-' . $serial);
         pb_backupbuddy::status('details', 'Backup stopped. Any remaining processes or files will time out and be cleaned up by scheduled housekeeping functionality.', $serial);
         pb_backupbuddy::status('action', 'halt_script', $serial);
         // Halt JS on page.
     }
     // Make sure the serial exists.
     if ($serial != '') {
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt';
         $backup_options = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = true, $ignore_lock = true);
         $backup =& $backup_options->options;
         if (true !== ($result = $backup_options->is_ok())) {
             pb_backupbuddy::status('error', 'Error #8329754.  Error retrieving fileoptions file `' . $fileoptions_file . '`. Error details `' . $result . '`.', $serial);
             pb_backupbuddy::status('action', 'halt_script', $serial);
             die;
         }
     }
     if ($serial == '' || !is_array($backup)) {
         pb_backupbuddy::status('error', 'Error #9031. Invalid backup serial (' . htmlentities($serial) . '). Please check directory permissions for your wp-content/uploads/ directory recursively, your PHP error_log for any errors, and that you have enough free disk space. If seeking support please provide this full status log and PHP error log. Fatal error. Verify this fileoptions file exists `' . $fileoptions_file . '`', $serial);
         pb_backupbuddy::status('action', 'halt_script', $serial);
         die;
     } else {
         // Verify init completed.
         if (false === $backup['init_complete']) {
             if (0 >= $init_wait_retry_count) {
                 // Waited too long for init to complete, must be something wrong
                 pb_backupbuddy::status('error', 'Error #9033: The pre-backup initialization for serial `' . $serial . '` was unable save pre-backup initialization options (init_complete===false) possibly because the pre-backup initialization step did not complete. If the log indicates the pre-backup procedure did indeed complete then something prevented BackupBuddy from updating the database such as an misconfigured caching plugin. Check for any errors above or in logs. Verify permissions & that there is enough server memory. See the BackupBuddy "Server Information" page to help assess your server.', $serial);
                 pb_backupbuddy::status('action', 'halt_script', $serial);
             } else {
                 pb_backupbuddy::status('details', 'Waiting for the pre-backup initialization for serial `' . $serial . '` to complete: ' . $init_wait_retry_count, $serial);
                 pb_backupbuddy::status('action', 'wait_init', $serial);
             }
         }
         //***** Begin outputting status of the current step.
         foreach ($backup['steps'] as $step) {
             if ($step['start_time'] != -1 && $step['start_time'] != 0 && $step['finish_time'] == 0) {
                 // A step isnt mark to skip, has begun but has not finished. This should not happen but the WP cron is funky. Wait a while before continuing.
                 // For database dump step output the SQL file current size.
                 if ($step['function'] == 'backup_create_database_dump') {
                     $sql_file = $backup['temp_directory'] . 'db_1.sql';
                     if (file_exists($sql_file)) {
                         $sql_filesize = pb_backupbuddy::$format->file_size(filesize($sql_file));
                     } else {
                         // No SQL file yet.
                         $sql_filesize = '[SQL file not found yet]';
                     }
                     pb_backupbuddy::status('details', 'Current SQL database dump file size: ' . $sql_filesize . '.', $serial);
                 }
                 pb_backupbuddy::status('details', 'Waiting for function `' . $step['function'] . '` to complete. Started ' . (time() - $step['start_time']) . ' seconds ago.', $serial);
                 if (time() - $step['start_time'] > 300) {
                     pb_backupbuddy::status('warning', 'The function `' . $step['function'] . '` is taking an abnormally long time to complete (' . (time() - $step['start_time']) . ' seconds). The backup may have failed. If it does not increase in the next few minutes it most likely timed out. See the Status Log for details.', $serial);
                 }
             } elseif ($step['start_time'] == 0) {
                 // Step that has not started yet.
                 // Do nothing.
             } elseif ($step['start_time'] == -1) {
                 // Step marked for skipping (backup stop button hit).
                 // Do nothing.
             } else {
                 // Last case: Finished. Skip.
                 // Do nothing.
             }
         }
         //***** End outputting status of the current step.
         //***** Begin output of temp zip file size.
         $temporary_zip_directory = backupbuddy_core::getBackupDirectory() . 'temp_zip_' . $serial . '/';
         if (file_exists($temporary_zip_directory)) {
             // Temp zip file.
             $directory = opendir($temporary_zip_directory);
             while ($file = readdir($directory)) {
                 if ($file != '.' && $file != '..' && $file != 'exclusions.txt' && !preg_match('/.*\\.txt/', $file) && !preg_match('/pclzip.*\\.gz/', $file)) {
                     $stats = stat($temporary_zip_directory . $file);
                     //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|details|~|' . __('Temporary ZIP file size', 'it-l10n-backupbuddy' ) .': ' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";;
                     pb_backupbuddy::status('details', __('Temporary ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                     //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";
                     pb_backupbuddy::status('action', 'archive_size^' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                 }
             }
             closedir($directory);
             unset($directory);
         }
         //***** End output of temp zip file size.
         // Output different stuff to the browser depending on whether backup is finished or not.
         if ($backup['finish_time'] > 0) {
             // BACKUP FINISHED.
             // OUTPUT COMPLETED ZIP FINAL SIZE.
             if (file_exists($backup['archive_file'])) {
                 // Final zip file.
                 $stats = stat($backup['archive_file']);
                 //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|details|~|' . __('Completed backup final ZIP file size', 'it-l10n-backupbuddy' ) . ': ' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";;
                 pb_backupbuddy::status('details', '--- ' . __('New PHP process.'), $serial);
                 pb_backupbuddy::status('details', __('Completed backup final ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                 //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";
                 pb_backupbuddy::status('action', 'archive_size^' . pb_backupbuddy::$format->file_size($stats['size']), $serial);
                 $backup_finished = true;
             } else {
                 $purposeful_deletion = false;
                 foreach ($backup['steps'] as $step) {
                     if ($step['function'] == 'send_remote_destination') {
                         if ($step['args'][1] == true) {
                             pb_backupbuddy::status('details', 'Option to delete local backup after successful send enabled so local file deleted.');
                             $purposeful_deletion = true;
                             break;
                         }
                     }
                 }
                 if ($purposeful_deletion !== true) {
                     pb_backupbuddy::status('error', __('Backup reports success but unable to access final ZIP file. Verify permissions and ownership. If the error persists insure that server is properly configured with suphp and proper ownership & permissions.', 'it-l10n-backupbuddy'), $serial);
                 }
             }
             pb_backupbuddy::status('message', __('Backup successfully completed in ', 'it-l10n-backupbuddy') . ' ' . pb_backupbuddy::$format->time_duration($backup['finish_time'] - $backup['start_time']) . '.', $serial);
             pb_backupbuddy::status('action', 'finish_backup', $serial);
         } else {
             // NOT FINISHED
             //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . "|~|0|~|0|~|ping\n";
             pb_backupbuddy::status('message', __('Ping. Waiting for server . . .', 'it-l10n-backupbuddy'), $serial);
         }
         //***** Begin getting status log information.
         $return_status = '';
         $status_lines = pb_backupbuddy::get_status($serial, true, false, true);
         // Clear file, dont unlink file (pclzip cant handle files unlinking mid-zip), dont show getting status message.
         if ($status_lines !== false) {
             // Only add lines if there is status contents.
             foreach ($status_lines as $status_line) {
                 //$return_status .= '!' . $status_line[0] . '|' . $status_line[3] . '|' . $status_line[4] . '( ' . $status_line[1] . 'secs / ' . $status_line[2] . 'MB )' . "\n";
                 $return_status .= '!' . implode('|~|', $status_line) . "\n";
             }
         }
         //***** End getting status log information.
         echo $return_status;
         // Return messages.
     }
     die;
 }
    if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/wp-config.php') === true) {
        $pass = true;
    }
    if (false === $pass) {
        if (isset($options['excludes'])) {
            if (false !== stristr($options['excludes'], 'wp-config.')) {
                pb_backupbuddy::status('warning', 'Warning: An exclusion containing wp-config.php was found. Exclusions: `' . str_replace(array("\r", "\r\n", "\n"), '; ', $options['excludes']) . '`.');
            }
        }
    }
    $tests[] = array('test' => 'WordPress wp-config.php file (full backups only)', 'pass' => $pass);
}
// end if full backup.
// Get zip scan log details.
pb_backupbuddy::status('details', 'Retrieving zip scan log.');
$temp_details = pb_backupbuddy::get_status('zipbuddy_test');
// Get zipbuddy scan log.
$scan_log = array();
foreach ($temp_details as $temp_detail) {
    $scan_log[] = json_decode($temp_detail)->{'data'};
}
if (true !== $skipLogRedirect) {
    pb_backupbuddy::set_status_serial($previous_status_serial);
    // Stop redirecting log to a specific file & set back to what it was prior.
    pb_backupbuddy::status('details', 'Stopped temporary redirection of status logging.');
}
pb_backupbuddy::status('details', 'Calculating integrity scan status,');
// Check for any failed tests.
$is_ok = true;
$integrity_description = '';
foreach ($tests as $test) {
Esempio n. 6
0
 function backup_integrity_check($file, $fileoptions = '', $options = array())
 {
     $options = array_merge(array('skip_database_dump' => '0'), $options);
     pb_backupbuddy::status('details', 'Started backup_integrity_check() function.');
     $serial = $this->get_serial_from_file($file);
     // User selected to rescan a file.
     if (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         pb_backupbuddy::alert('Rescanning backup integrity for backup file `' . basename($file) . '`');
     }
     if ($fileoptions != '') {
         $backup_options =& $fileoptions;
     } else {
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $backup_options = new pb_backupbuddy_fileoptions(pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
         // Will create file to hold integrity data if nothing exists.
         if (true !== ($result = $backup_options->is_ok())) {
             pb_backupbuddy::status('error', __('Fatal Error #9034 C. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error on file `' . pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt' . '`: ' . $result);
             pb_backupbuddy::status('action', 'halt_script');
             // Halt JS on page.
             return false;
         }
         if (isset($backup_options->options['profile'])) {
             $options = $backup_options->options['profile'];
             $options = array_merge(pb_backupbuddy::settings('profile_defaults'), $options);
         }
     }
     if (isset($backup_options->options['integrity']) && count($backup_options->options['integrity']) > 0 && pb_backupbuddy::_GET('reset_integrity') != $serial) {
         // Already have integrity data and NOT resetting this one.
         pb_backupbuddy::status('details', 'Integrity data for backup `' . $serial . '` is cached; not scanning again.');
         return true;
     } elseif (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         // Resetting this one.
         pb_backupbuddy::status('details', 'Resetting backup integrity stats for backup with serial `' . $serial . '`.');
     } else {
         // No integrity data; not resetting. Just keep going...
     }
     if (pb_backupbuddy::$options['profiles'][0]['integrity_check'] == '0' && pb_backupbuddy::_GET('reset_integrity') == '') {
         // Integrity checking disabled. Allows run if manually rescanning on backups page.
         pb_backupbuddy::status('details', 'Integrity check disabled. Skipping scan.');
         $file_stats = @stat($file);
         if ($file_stats === false) {
             // stat failure.
             pb_backupbuddy::status('error', 'Error #4539774. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
             $file_size = 0;
             $file_modified = 0;
         } else {
             // stat success.
             $file_size = $file_stats['size'];
             $file_modified = $file_stats['mtime'];
         }
         unset($file_stats);
         $integrity = array('status' => 'Unknown', 'tests' => array(), 'scan_time' => 0, 'detected_type' => 'unknown', 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => false);
         $backup_options->options['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
         $backup_options->save();
         return true;
     }
     //***** BEGIN CALCULATING STATUS DETAILS.
     $backup_type = '';
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(pb_backupbuddy::$options['backup_directory']);
     }
     pb_backupbuddy::status('details', 'Redirecting status logging temporarily.');
     $previous_status_serial = pb_backupbuddy::get_status_serial();
     // Store current status serial setting to reset back later.
     pb_backupbuddy::set_status_serial('zipbuddy_test');
     // Redirect logging output to a certain log file.
     // Look for comment.
     pb_backupbuddy::status('details', 'Verifying comment in zip archive.');
     $raw_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($file);
     $comment = pb_backupbuddy::$classes['core']->normalize_comment_data($raw_comment);
     $comment = $comment['note'];
     $tests = array();
     // Check for DAT file.
     $pass = false;
     pb_backupbuddy::status('details', 'Verifying DAT file in zip archive.');
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/backupbuddy_dat.php') === true) {
         // Post 2.0 full backup
         $backup_type = 'full';
         $pass = true;
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/backupbuddy_dat.php') === true) {
         // Pre 2.0 full backup
         $backup_type = 'full';
         $pass = true;
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'backupbuddy_dat.php') === true) {
         // DB backup
         $backup_type = 'db';
         $pass = true;
     }
     $tests[] = array('test' => 'BackupBackup data file exists', 'pass' => $pass);
     // Skip database checks if needed.
     //if ( $options['skip_database_dump'] != '1' ) {
     // Check for DB SQL file.
     $pass = false;
     pb_backupbuddy::status('details', 'Verifying database SQL file in zip archive.');
     if ($options['skip_database_dump'] == '1') {
         pb_backupbuddy::status('warning', 'WARNING: Database .SQL file does NOT exist because the database dump has been set to be SKIPPED based on settings. Use with cuation!');
     } else {
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/db_1.sql') === true) {
             // post 2.0 full backup
             $backup_type = 'full';
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/db.sql') === true) {
             // pre 2.0 full backup
             $backup_type = 'full';
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db_1.sql') === true) {
             // db only backup 2.0+
             $backup_type = 'db';
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db.sql') === true) {
             // db only backup pre-2.0
             $backup_type = 'db';
             $pass = true;
         }
     }
     $tests[] = array('test' => 'Database SQL file exists', 'pass' => $pass);
     // NOTE: As of 4.0 ALL db dumps append into db_1.sql. Future: break out into individual files. Check DB SQL files for BREAKOUT tables.
     /*
     if ( isset( $backup_options->options['breakout_tables'] ) && ( count( $backup_options->options['breakout_tables'] ) > 0 ) ) {
     	foreach( $backup_options->options['breakout_tables'] as $breakout_table ) {
     		$pass = false;
     		if ( pb_backupbuddy::$classes['zipbuddy']->file_exists( $file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/' . $breakout_table . '.sql' ) === true ) { // Full backup.
     			$pass = true;
     		}
     		if ( pb_backupbuddy::$classes['zipbuddy']->file_exists( $file, $breakout_table . '.sql' ) === true ) { // DB backup.
     			$pass = true;
     		}
     		$tests[] = array(
     			'test'		=>	'Breakout Database SQL file exists (' . $breakout_table . '.sql)',
     			'pass'		=>	$pass,
     		);
     	}
     }
     */
     // }
     if ('full' == $backup_type) {
         // Check for WordPress config file.
         $pass = false;
         pb_backupbuddy::status('details', 'Verifying WordPress wp-config.php configuration file in zip archive.');
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-config.php') === true) {
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/wp-config.php') === true) {
             $pass = true;
         }
         $tests[] = array('test' => 'WordPress wp-config.php exists (full backups only)', 'pass' => $pass);
     }
     // Get zip scan log details.
     pb_backupbuddy::status('details', 'Retrieving zip scan log.');
     $temp_details = pb_backupbuddy::get_status('zipbuddy_test');
     // Get zipbuddy scan log.
     $scan_log = array();
     foreach ($temp_details as $temp_detail) {
         $scan_log[] = $temp_detail[4];
     }
     pb_backupbuddy::set_status_serial($previous_status_serial);
     // Stop redirecting log to a specific file & set back to what it was prior.
     pb_backupbuddy::status('details', 'Stopped temporary redirection of status logging.');
     pb_backupbuddy::status('details', 'Calculating integrity scan status,');
     // Check for any failed tests.
     $is_ok = true;
     $integrity_description = '';
     foreach ($tests as $test) {
         if ($test['pass'] !== true) {
             $is_ok = false;
             $error = 'Error #389434. Integrity test FAILED. Test: `' . $test['test'] . '`. ';
             pb_backupbuddy::status('error', $error);
             $integrity_description .= $error;
         }
     }
     if (true === $is_ok) {
         $integrity_status = 'Pass';
     } else {
         $integrity_status = 'Fail';
     }
     pb_backupbuddy::status('details', 'Status: `' . $integrity_status . '`. Description: `' . $integrity_description . '`.');
     //***** END CALCULATING STATUS DETAILS.
     // Get file information from file system.
     pb_backupbuddy::status('details', 'Getting file details such as size, timestamp, etc.');
     $file_stats = @stat($file);
     if ($file_stats === false) {
         // stat failure.
         pb_backupbuddy::status('error', 'Error #4539774b. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
         $file_size = 0;
         $file_modified = 0;
     } else {
         // stat success.
         $file_size = $file_stats['size'];
         $file_modified = $file_stats['ctime'];
         // Created time.
     }
     unset($file_stats);
     // Compile array of results for saving into data structure.
     $integrity = array('is_ok' => $is_ok, 'tests' => $tests, 'scan_time' => time(), 'scan_log' => $scan_log, 'detected_type' => $backup_type, 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => $comment);
     pb_backupbuddy::status('details', 'Saving backup file integrity check details.');
     $backup_options->options['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
     $backup_options->save();
     return $is_ok;
 }
Esempio n. 7
0
 //***** Begin getting status log information.
 if ('' != $backup['deployment_log']) {
     //error_log( print_r( $backup, true ) );
     if ('push' == $backup['deployment_direction']) {
         pb_backupbuddy::status('details', 'About to retrieve push deployment status log from `' . $backup['deployment_log'] . '`...', $serial);
         pb_backupbuddy::status('details', '** Begin External Log section (ImportBuddy)', $serial);
     } elseif ('pull' == $backup['deployment_direction']) {
         pb_backupbuddy::status('details', 'About to retrieve pull deployment status log from `' . $backup['deployment_log'] . '`...', $serial);
         pb_backupbuddy::status('details', '*** Begin External Log Section (Remote backup or ImportBuddy)', $serial);
     } else {
         pb_backupbuddy::status('error', 'Error #84377834: Deployment log set but direction missing.', $serial);
     }
 }
 // Get local status log and output it.
 //echo "\nEND_DEPLOY\n"; // In case prior end deploy signal did not go out.
 $status_lines = pb_backupbuddy::get_status($serial, true, false, true);
 // Clear file, dont unlink file, supress status retrieval msg.
 echo implode('', $status_lines);
 // DEPLOYMENT OUTPUT.
 if ('' != $backup['deployment_log']) {
     echo "\nSTART_DEPLOY\n";
     if ('push' == $backup['deployment_direction']) {
         // *** PUSH
         $response = wp_remote_get($backup['deployment_log'], array('method' => 'GET', 'timeout' => 10, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null, 'cookies' => array()));
         if (is_wp_error($response)) {
             // Loopback failed. Some kind of error.
             $error = $response->get_error_message();
             pb_backupbuddy::status('error', 'Error retrieving remote deployment log. Details: `' . $error . '`.', $serial);
         } else {
             if ('200' == $response['response']['code']) {
                 //error_log( print_r( $response, true ) );
Esempio n. 8
0
 /**
  *	status()
  *
  *	Write a status line into an existing textarea created with the status_box() function.
  *
  *	@param			$type		string		message, details, error, or warning. Currently not in use.
  *	@param			$message	string		Message to append to the status box.
  *	@return			null
  */
 function status($type, $message)
 {
     pb_backupbuddy::status($type, $message);
     $status_lines = pb_backupbuddy::get_status('ms_import', true, true, true);
     // $serial = '', $clear_retrieved = true, $erase_retrieved = true, $hide_getting_status = false
     if ($status_lines !== false) {
         // Only add lines if there is status contents.
         foreach ($status_lines as $status_line) {
             $status_line[0] = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($status_line[0]));
             $status_line[1] .= 'sec';
             $status_line[2] .= 'MB';
             echo '<script type="text/javascript">jQuery( "#importbuddy_status" ).append( "\\n' . implode("\t", $status_line) . '");	textareaelem = document.getElementById( "importbuddy_status" );	textareaelem.scrollTop = textareaelem.scrollHeight;	</script>';
             pb_backupbuddy::flush();
         }
     }
     /*
     $message = htmlentities( addslashes( $message ) );
     $status = date( $this->_parent->_parent->_timestamp, time() ) . ': ' . $message;
     
     echo '<script type="text/javascript">jQuery( "#importbuddy_status" ).append( "\n' . $status . '");	textareaelem = document.getElementById( "importbuddy_status" );	textareaelem.scrollTop = textareaelem.scrollHeight;	</script>';
     pb_backupbuddy::flush();
     
     if ( $type == 'error' ) {
     	$this->log( $message, 'error' );
     } elseif ( $type == 'warning' ) {
     	$this->log( $message, 'warning' );
     } else {
     	$this->log( '[' . $type . ']' . $message, 'all' );
     }
     */
 }
Esempio n. 9
0
 /**
  *	status()
  *
  *	Write a status line into an existing textarea created with the status_box() function.
  *
  *	@param			$type		string		message, details, error, or warning. Currently not in use.
  *	@param			$message	string		Message to append to the status box.
  *	@return			null
  */
 function status($type, $message)
 {
     pb_backupbuddy::status($type, $message);
     $status_lines = pb_backupbuddy::get_status('ms_import', true, true, true);
     // $serial = '', $clear_retrieved = true, $erase_retrieved = true, $hide_getting_status = false
     if ($status_lines !== false) {
         // Only add lines if there is status contents.
         foreach ($status_lines as $status_line) {
             $status_line[0] = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($status_line[0]));
             $status_line[1] .= 'sec';
             $status_line[2] .= 'MB';
             echo '<script type="text/javascript">jQuery( "#importbuddy_status" ).append( "\\n' . implode("\t", $status_line) . '");	textareaelem = document.getElementById( "importbuddy_status" );	textareaelem.scrollTop = textareaelem.scrollHeight;	</script>';
             pb_backupbuddy::flush();
         }
     }
 }
Esempio n. 10
0
 public function backup_status()
 {
     // Make sure the serial exists.
     if (pb_backupbuddy::_POST('serial') == '' || empty(pb_backupbuddy::$options['backups'][pb_backupbuddy::_POST('serial')])) {
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|error|~|Error #9031. Invalid backup serial (' . htmlentities(pb_backupbuddy::_POST('serial')) . '). Please check directory permissions for your wp-content/uploads/ directory recursively, your PHP error_log for any errors, and that you have enough free disk space. Fatal error.' . "\n";
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|halt_script' . "\n";
     } else {
         $return_status = '';
         //error_log( print_r( pb_backupbuddy::$options['backups'], true ) );
         foreach (pb_backupbuddy::$options['backups'][pb_backupbuddy::_POST('serial')]['steps'] as $step) {
             if ($step['start_time'] != 0 && $step['finish_time'] == 0) {
                 // A step has begun but has not finished. This should not happen but the WP cron is funky. Wait a while before continuing.
                 // For database dump step output the SQL file current size.
                 if ($step['function'] == 'backup_create_database_dump') {
                     $sql_file = pb_backupbuddy::$options['backups'][pb_backupbuddy::_POST('serial')]['temp_directory'] . 'db_1.sql';
                     if (file_exists($sql_file)) {
                         $sql_filesize = pb_backupbuddy::$format->file_size(filesize($sql_file));
                     } else {
                         // No SQL file yet.
                         $sql_filesize = '[SQL file not found yet]';
                     }
                     pb_backupbuddy::status('details', 'Current SQL database dump file size: ' . $sql_filesize . '.', pb_backupbuddy::_POST('serial'));
                 }
                 pb_backupbuddy::status('details', 'Waiting for function `' . $step['function'] . '` to complete. Started ' . (time() - $step['start_time']) . ' seconds ago.', pb_backupbuddy::_POST('serial'));
                 if (time() - $step['start_time'] > 300) {
                     pb_backupbuddy::status('warning', 'The function `' . $step['function'] . '` is taking an abnormally long time to complete (' . (time() - $step['start_time']) . ' seconds). The backup may have stalled.', pb_backupbuddy::_POST('serial'));
                 }
             } elseif ($step['start_time'] == 0) {
                 // Step that has not started yet.
             } else {
                 // Last case: Finished. Skip.
                 // Do nothing.
             }
         }
         $status_lines = pb_backupbuddy::get_status(pb_backupbuddy::_POST('serial'), true, false, true);
         // Clear file, dont unlink file (pclzip cant handle files unlinking mid-zip), dont show getting status message.
         if ($status_lines !== false) {
             // Only add lines if there is status contents.
             foreach ($status_lines as $status_line) {
                 //$return_status .= '!' . $status_line[0] . '|' . $status_line[3] . '|' . $status_line[4] . '( ' . $status_line[1] . 'secs / ' . $status_line[2] . 'MB )' . "\n";
                 $return_status .= '!' . implode('|~|', $status_line) . "\n";
             }
         }
         $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . "|~|0|~|0|~|ping\n";
         /********** Begin file sizes for status updates. *********/
         $temporary_zip_directory = pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . pb_backupbuddy::_POST('serial') . '/';
         if (file_exists($temporary_zip_directory)) {
             // Temp zip file.
             $directory = opendir($temporary_zip_directory);
             while ($file = readdir($directory)) {
                 if ($file != '.' && $file != '..' && $file != 'exclusions.txt') {
                     $stats = stat($temporary_zip_directory . $file);
                     $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|details|~|' . __('Temporary ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
                     $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
                 }
             }
             closedir($directory);
             unset($directory);
         }
         if (file_exists(pb_backupbuddy::$options['backups'][pb_backupbuddy::_POST('serial')]['archive_file'])) {
             // Final zip file.
             $stats = stat(pb_backupbuddy::$options['backups'][pb_backupbuddy::_POST('serial')]['archive_file']);
             $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|details|~|' . __('Completed backup final ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
             $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
         }
         /********** End file sizes for status updates. *********/
         // Return messages.
         echo $return_status;
     }
     die;
 }
Esempio n. 11
0
 public static function backup_integrity_check($file, $fileoptions = '', $options = array(), $skipLogRedirect = false)
 {
     pb_backupbuddy::status('details', 'Started backup_integrity_check() function.');
     $serial = self::get_serial_from_file($file);
     // User selected to rescan a file.
     if (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         pb_backupbuddy::alert('Rescanning backup integrity for backup file `' . basename($file) . '`');
         pb_backupbuddy::flush();
     }
     $options = array_merge(array('skip_database_dump' => '0'), $options);
     $scan_notes = array();
     // Get backup fileoptions.
     if ($fileoptions != '') {
         $backup_options =& $fileoptions;
     } else {
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
         // Will create file to hold integrity data if nothing exists.
         if (true !== ($result = $backup_options->is_ok())) {
             pb_backupbuddy::status('error', __('Fatal Error #9034 C. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error on file `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' . '`: ' . $result);
             pb_backupbuddy::status('haltScript', '');
             // Halt JS on page.
             return false;
         }
     }
     if (isset($backup_options->options['profile'])) {
         $options = $backup_options->options['profile'];
         $options = array_merge(pb_backupbuddy::settings('profile_defaults'), $options);
     }
     // Return if cached.
     if (isset($backup_options->options['integrity']) && count($backup_options->options['integrity']) > 0 && pb_backupbuddy::_GET('reset_integrity') != $serial) {
         // Already have integrity data and NOT resetting this one.
         pb_backupbuddy::status('details', 'Integrity data for backup `' . $serial . '` is cached; not scanning again.');
         return $backup_options->options['integrity'];
     } elseif (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         // Resetting this one.
         pb_backupbuddy::status('details', 'Resetting backup integrity stats for backup with serial `' . $serial . '`.');
     } else {
         // No integrity data; not resetting. Just keep going...
     }
     // Integrity check disabled. Skip.
     if (pb_backupbuddy::$options['profiles'][0]['integrity_check'] == '0' && pb_backupbuddy::_GET('reset_integrity') == '' && isset($options['integrity_check']) && $options['integrity_check'] == '0') {
         // Integrity checking disabled. Allows run if manually rescanning on backups page.
         pb_backupbuddy::status('details', 'Integrity check disabled. Skipping scan.');
         $file_stats = @stat($file);
         if ($file_stats === false) {
             // stat failure.
             pb_backupbuddy::status('error', 'Error #4539774. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
             $file_size = 0;
             $file_modified = 0;
         } else {
             // stat success.
             $file_size = $file_stats['size'];
             $file_modified = $file_stats['mtime'];
         }
         unset($file_stats);
         $integrity = array('status' => 'Unknown', 'tests' => array(), 'scan_time' => 0, 'detected_type' => 'unknown', 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => false);
         $backup_options->options['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
         $backup_options->save();
         return $backup_options->options['integrity'];
     }
     //***** BEGIN CALCULATING STATUS DETAILS.
     $backup_type = '';
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
     }
     $previous_status_serial = pb_backupbuddy::get_status_serial();
     // Store current status serial setting to reset back later.
     if (true !== $skipLogRedirect) {
         pb_backupbuddy::status('details', 'Redirecting status logging temporarily.');
         pb_backupbuddy::set_status_serial('zipbuddy_test');
         // Redirect logging output to a certain log file.
     }
     // Look for comment.
     pb_backupbuddy::status('details', 'Verifying comment in zip archive.');
     $raw_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($file);
     $comment = backupbuddy_core::normalize_comment_data($raw_comment);
     $comment = $comment['note'];
     $tests = array();
     pb_backupbuddy::status('details', 'NOTE: It is normal to see several "File not found" messages in the next several log lines.');
     // Check for DAT file.
     $pass = false;
     pb_backupbuddy::status('details', 'Verifying DAT file in zip archive.');
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/backupbuddy_dat.php') === true) {
         // Post 2.0 full backup
         $backup_type = 'full';
         $pass = true;
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/backupbuddy_dat.php') === true) {
         // Pre 2.0 full backup
         $backup_type = 'full';
         $pass = true;
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'backupbuddy_dat.php') === true) {
         // DB backup
         $backup_type = 'db';
         $pass = true;
     }
     $tests[] = array('test' => 'BackupBuddy data file', 'pass' => $pass);
     if (isset($options['type']) && 'files' == $options['type']) {
         pb_backupbuddy::status('details', 'Files only backup type so skipping scan of database files in backup as it is not applicable.');
     } else {
         // Non-files only backup so check for DB.
         // Check for DB .sql file.
         $pass = false;
         $db_test_note = '';
         pb_backupbuddy::status('details', 'Verifying database SQL file in zip archive.');
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/db_1.sql') === true) {
             // post 2.0 full backup
             $backup_type = 'full';
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/db.sql') === true) {
             // pre 2.0 full backup
             $backup_type = 'full';
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db_1.sql') === true) {
             // db only backup 2.0+
             $backup_type = 'db';
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db.sql') === true) {
             // db only backup pre-2.0
             $backup_type = 'db';
             $pass = true;
         }
         if ('1' == $options['skip_database_dump']) {
             if (false === $pass) {
                 pb_backupbuddy::status('warning', 'WARNING: Database .SQL does NOT exist because database dump was set to be skipped based on settings. Use with caution. The database was NOT backed up.');
             } else {
                 // DB dump set to be skipped but was found. Just in case...
                 pb_backupbuddy::status('warning', 'Warning #58458749. Database dump was set to be skip _BUT_ database file WAS found?');
             }
             $pass = true;
             $db_test_note = ' <span class="pb_label pb_label-warning">' . __('Database skipped', 'it-l10n-backupbuddy') . '</span>';
             $scan_notes[] = '<span class="pb_label pb_label-warning">' . __('Database skipped', 'it-l10n-backupbuddy') . '</span>';
         }
         $tests[] = array('test' => 'Database SQL file' . $db_test_note, 'pass' => $pass);
     }
     // Use filename to determine backup type if detectable as it is more authoritive than the above guesses.
     if (false !== stristr($file, '-db-')) {
         $backup_type = 'db';
     } elseif (false !== stristr($file, '-full-')) {
         $backup_type = 'full';
     } elseif (false !== stristr($file, '-files-')) {
         $backup_type = 'files';
     } else {
         // Filename determination was not conclusive. Leave as-is based on deduced backup type determined earlier.
     }
     // Check for wp-config.php file if full backup.
     if ('full' == $backup_type) {
         $pass = false;
         pb_backupbuddy::status('details', 'Verifying WordPress wp-config.php configuration file in zip archive.');
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-config.php') === true) {
             $pass = true;
         }
         if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/wp-config.php') === true) {
             $pass = true;
         }
         if (false === $pass) {
             if (isset($options['excludes'])) {
                 if (false !== stristr($options['excludes'], 'wp-config.')) {
                     pb_backupbuddy::status('warning', 'Warning: An exclusion containing wp-config.php was found. Exclusions: `' . str_replace(array("\r", "\r\n", "\n"), '; ', $options['excludes']) . '`.');
                 }
             }
         }
         $tests[] = array('test' => 'WordPress wp-config.php file (full backups only)', 'pass' => $pass);
     }
     // end if full backup.
     // Get zip scan log details.
     pb_backupbuddy::status('details', 'Retrieving zip scan log.');
     $temp_details = pb_backupbuddy::get_status('zipbuddy_test');
     // Get zipbuddy scan log.
     $scan_log = array();
     foreach ($temp_details as $temp_detail) {
         $scan_log[] = json_decode($temp_detail)->{'data'};
     }
     if (true !== $skipLogRedirect) {
         pb_backupbuddy::set_status_serial($previous_status_serial);
         // Stop redirecting log to a specific file & set back to what it was prior.
         pb_backupbuddy::status('details', 'Stopped temporary redirection of status logging.');
     }
     pb_backupbuddy::status('details', 'Calculating integrity scan status,');
     // Check for any failed tests.
     $is_ok = true;
     $integrity_description = '';
     foreach ($tests as $test) {
         if ($test['pass'] !== true) {
             $is_ok = false;
             $error = 'Error #389434. Integrity test FAILED. Test: `' . $test['test'] . '`. ';
             pb_backupbuddy::status('error', $error);
             $integrity_description .= $error;
         }
     }
     if (true === $is_ok) {
         $integrity_status = 'Pass';
     } else {
         $integrity_status = 'Fail';
     }
     pb_backupbuddy::status('details', 'Status: `' . $integrity_status . '`. Description: `' . $integrity_description . '`.');
     //***** END CALCULATING STATUS DETAILS.
     // Get file information from file system.
     pb_backupbuddy::status('details', 'Getting file details such as size, timestamp, etc.');
     $file_stats = @stat($file);
     if ($file_stats === false) {
         // stat failure.
         pb_backupbuddy::status('error', 'Error #4539774b. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
         $file_size = 0;
         $file_modified = 0;
     } else {
         // stat success.
         $file_size = $file_stats['size'];
         $file_modified = $file_stats['mtime'];
         // Created time.
     }
     unset($file_stats);
     // Compile array of results for saving into data structure.
     $integrity = array('is_ok' => $is_ok, 'tests' => $tests, 'scan_time' => time(), 'scan_log' => $scan_log, 'scan_notes' => $scan_notes, 'detected_type' => $backup_type, 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => $comment);
     pb_backupbuddy::status('details', 'Saving backup file integrity check details.');
     $backup_options->options['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
     $backup_options->save();
     return $backup_options->options['integrity'];
 }
Esempio n. 12
0
<?php

if (!defined('PB_IMPORTBUDDY') || true !== PB_IMPORTBUDDY) {
    die('<html></html>');
}
if ('true' != pb_backupbuddy::_GET('deploy')) {
    die('Access denied.');
}
// Only allow access to this file if it has a serial hiding it. Used by deployment.
global $importbuddy_file;
$importFileSerial = backupbuddy_core::get_serial_from_file($importbuddy_file);
if ('' == $importFileSerial) {
    die('Access denied.');
}
pb_backupbuddy::status('details', '*** End ImportBuddy Log section');
$status_lines = pb_backupbuddy::get_status('', true, false, true);
// Clear file, dont unlink file, supress status retrieval msg.
echo implode('', $status_lines);
Esempio n. 13
0
 function backup_integrity_check($file)
 {
     pb_backupbuddy::status('details', 'Started backup_integrity_check() function.');
     $serial = $this->get_serial_from_file($file);
     // User selected to rescan a file.
     if (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         pb_backupbuddy::alert('Rescanning backup integrity for backup file `' . basename($file) . '`');
     }
     if (isset(pb_backupbuddy::$options['backups'][$serial]['integrity']) && count(pb_backupbuddy::$options['backups'][$serial]['integrity']) > 0 && pb_backupbuddy::_GET('reset_integrity') != $serial) {
         // Already have integrity data and NOT resetting this one.
         pb_backupbuddy::status('details', 'Integrity data for backup `' . $serial . '` is cached; not scanning again.');
         return true;
     } elseif (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         // Resetting this one.
         pb_backupbuddy::status('details', 'Resetting backup integrity stats for backup with serial `' . $serial . '`.');
     } else {
         // No integrity data; not resetting. Just keep going...
     }
     if (pb_backupbuddy::$options['integrity_check'] == '0') {
         // Integrity checking disabled.
         pb_backupbuddy::status('details', 'Integrity check disabled. Skipping scan.');
         $file_stats = @stat($file);
         if ($file_stats === false) {
             // stat failure.
             pb_backupbuddy::status('error', 'Error #4539774. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
             $file_size = 0;
             $file_modified = 0;
         } else {
             // stat success.
             $file_size = $file_stats['size'];
             $file_modified = $file_stats['mtime'];
         }
         unset($file_stats);
         $integrity = array('status' => 'Unknown', 'status_details' => __('Integrity checking disabled based on settings. This file has not been verified.', 'it-l10n-backupbuddy'), 'scan_time' => 0, 'detected_type' => 'unknown', 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => false);
         pb_backupbuddy::$options['backups'][$serial]['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
         pb_backupbuddy::save();
         return true;
     }
     //***** BEGIN CALCULATING STATUS DETAILS.
     // Status defaults.
     $status_details = array('found_dat' => false, 'found_sql' => false, 'found_wpconfig' => false, 'scan_log' => '');
     $backup_type = '';
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(pb_backupbuddy::$options['backup_directory']);
     }
     pb_backupbuddy::status('details', 'Redirecting status logging temporarily.');
     $previous_status_serial = pb_backupbuddy::get_status_serial();
     // Store current status serial setting to reset back later.
     pb_backupbuddy::set_status_serial('zipbuddy_test');
     // Redirect logging output to a certain log file.
     // Look for comment.
     pb_backupbuddy::status('details', 'Verifying comment in zip archive.');
     $raw_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($file);
     $comment = pb_backupbuddy::$classes['core']->normalize_comment_data($raw_comment);
     $comment = $comment['note'];
     // Check for DAT file.
     pb_backupbuddy::status('details', 'Verifying DAT file in zip archive.');
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/backupbuddy_dat.php') === true) {
         // Post 2.0 full backup
         $status_details['found_dat'] = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/backupbuddy_dat.php') === true) {
         // Pre 2.0 full backup
         $status_details['found_dat'] = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'backupbuddy_dat.php') === true) {
         // DB backup
         $status_details['found_dat'] = true;
         $backup_type = 'db';
     }
     // Check for DB SQL file.
     pb_backupbuddy::status('details', 'Verifying database SQL file in zip archive.');
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/db_1.sql') === true) {
         // post 2.0 full backup
         $status_details['found_sql'] = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/db.sql') === true) {
         // pre 2.0 full backup
         $status_details['found_sql'] = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db_1.sql') === true) {
         // db only backup 2.0+
         $status_details['found_sql'] = true;
         $backup_type = 'db';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'db.sql') === true) {
         // db only backup pre-2.0
         $status_details['found_sql'] = true;
         $backup_type = 'db';
     }
     // Check for WordPress config file.
     pb_backupbuddy::status('details', 'Verifying WordPress wp-config.php configuration file in zip archive.');
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-config.php') === true) {
         $status_details['found_wpconfig'] = true;
         $backup_type = 'full';
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/wp-config.php') === true) {
         $status_details['found_wpconfig'] = true;
         $backup_type = 'full';
     }
     // Get zip scan log details.
     pb_backupbuddy::status('details', 'Retrieving zip scan log.');
     $temp_details = pb_backupbuddy::get_status('zipbuddy_test');
     // Get zipbuddy scan log.
     foreach ($temp_details as $temp_detail) {
         $status_details['scan_log'][] = $temp_detail[4];
     }
     pb_backupbuddy::set_status_serial($previous_status_serial);
     // Stop redirecting log to a specific file & set back to what it was prior.
     pb_backupbuddy::status('details', 'Stopped temporary redirection of status logging.');
     // Calculate status descriptions.
     pb_backupbuddy::status('details', 'Calculating integrity scan status,');
     $integrity_status = 'pass';
     // Default.
     if ($status_details['found_dat'] !== true) {
         $integrity_status = 'fail';
         $integrity_description .= __('Error #7843564: Missing DAT file.', 'it-l10n-backupbuddy');
     }
     if ($status_details['found_sql'] !== true) {
         $integrity_status = 'fail';
         $integrity_description .= __('Error #4664236: Missing database SQL file.', 'it-l10n-backupbuddy');
     }
     if ($backup_type == 'full' && $status_details['found_wpconfig'] !== true) {
         $integrity_status = 'fail';
         $integrity_description .= __('Error #47834674: Missing wp-config.php file.', 'it-l10n-backupbuddy');
     }
     if ($integrity_status == 'pass') {
         // All tests passed.
         $integrity_description = __('All tests passed.', 'it-l10n-backupbuddy');
     }
     pb_backupbuddy::status('details', 'Status: `' . $integrity_status . '`. Description: `' . $integrity_description . '`.');
     //$integrity_description .= '<br><br>' . __('Technical Details', 'it-l10n-backupbuddy' ) . ':<br />' . $integrity_zipresult_details;
     //***** END CALCULATING STATUS DETAILS.
     // Get file information from file system.
     pb_backupbuddy::status('details', 'Getting file details such as size, timestamp, etc.');
     $file_stats = @stat($file);
     if ($file_stats === false) {
         // stat failure.
         pb_backupbuddy::status('error', 'Error #4539774b. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
         $file_size = 0;
         $file_modified = 0;
     } else {
         // stat success.
         $file_size = $file_stats['size'];
         $file_modified = $file_stats['ctime'];
         // Created time.
     }
     unset($file_stats);
     // Compile array of results for saving into data structure.
     $integrity = array('status' => $integrity_status, 'status_details' => $status_details, 'scan_time' => time(), 'detected_type' => $backup_type, 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => $comment);
     pb_backupbuddy::status('details', 'Saving backup file integrity check details.');
     pb_backupbuddy::$options['backups'][$serial]['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
     pb_backupbuddy::save();
     //pb_backupbuddy::$classes['zipbuddy']->clear_status();
     if ($integrity_status == 'pass') {
         // 100% success
         return true;
     } else {
         return false;
     }
 }