function backup_zip_files() { $this->status('action', 'start_files'); //sleep(7); $excludes = trim($this->_options['excludes']); $excludes = explode("\n", $excludes); //Clean up directory exclusions. foreach ($excludes as $exclude_id => $exclude_value) { if (empty($exclude_value)) { unset($excludes[$exclude_id]); } } // Add backup archive directory to be excluded. array_push($excludes, ltrim(str_replace(rtrim(ABSPATH, '\\\\/'), '', $this->_options['backup_directory']), ' \\/')); // Exclude backup directory with other archives. /* if ( $this->_options['force_compatibility'] == 1 ) { $this->status( 'message', 'Forcing compatibility mode (PCLZip) based on settings. This is slower and less reliable.' ); $this->_parent->_zipbuddy->set_zip_methods( array( 'pclzip' ) ); } */ if ($this->_options['compression'] == '1') { $compression = true; } else { $compression = false; } if ($this->_backup['type'] == 'full') { $directory_to_add = ABSPATH; } elseif ($this->_backup['type'] == 'db') { $directory_to_add = $this->_backup['temp_directory']; } else { $this->status('error', __('Backup FAILED. Unknown backup type.', 'it-l10n-backupbuddy')); $this->status('action', 'halt_script'); // Halt JS on page. } if ($this->_options['log_level'] == 3) { // If full logging mode then output exec() response to details. $quiet_response = false; } else { $quiet_response = true; } $this->_parent->_zipbuddy->set_status_callback(array(&$this, 'status')); // Set logging callback. if (defined('PB_DEMO_MODE')) { $this->status('message', 'Operating in demonstration mode. Backup file creation will be skipped.'); } else { if ($this->_parent->_zipbuddy->add_directory_to_zip($this->_backup['archive_file'], $directory_to_add, $compression, $excludes, $this->_backup['temporary_zip_directory'], $this->_backup['force_compatibility'], $quiet_response) === true) { $this->status('message', __('Backup ZIP file successfully created.', 'it-l10n-backupbuddy')); if (chmod($this->_backup['archive_file'], 0644)) { $this->status('details', __('Chmod to 0644 succeeded.', 'it-l10n-backupbuddy')); } else { $this->status('details', __('Chmod to 0644 failed.', 'it-l10n-backupbuddy')); } } else { $this->status('error', __('Backup FAILED. Unable to successfully generate ZIP archive. Error #3382.', 'it-l10n-backupbuddy')); $this->status('error', __('Error #3382 help: http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#3382', 'it-l10n-backupbuddy')); $this->status('action', 'halt_script'); // Halt JS on page. return false; } } // Need to make sure the database connection is active // This is not essential so use include and not require (suppress any warning) @(include_once $this->_pluginPath . '/lib/wpdbutils/wpdbutils.php'); if (class_exists('pluginbuddy_wpdbutils')) { // This is the database object we want to use global $wpdb; // Get our helper object and let it use us to output status messages $dbhelper = new pluginbuddy_wpdbutils($wpdb, $this); $dbhelper->set_status_callback(array(&$this, 'status')); // If we cannot kick the database into life then signal the error and return false which will stop the backup // Otherwise all is ok and we can just fall through and let the function return true if (!$dbhelper->kick()) { $this->status('error', __('Backup FAILED. Backup file produced but Database Server has gone away, unable to schedule next backup step', 'it-l10n-backupbuddy')); return false; } } else { // Utils not available so cannot verify database connection status - just notify $this->status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy')); } return true; }