本文整理汇总了PHP中pb_backupbuddy::cron_tag方法的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy::cron_tag方法的具体用法?PHP pb_backupbuddy::cron_tag怎么用?PHP pb_backupbuddy::cron_tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pb_backupbuddy
的用法示例。
在下文中一共展示了pb_backupbuddy::cron_tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cron_next_step
function cron_next_step($spawn_cron = true, $future_offset = 0)
{
if ('1' == pb_backupbuddy::$options['skip_spawn_cron_call']) {
pb_backupbuddy::status('details', 'Advanced option to skip call to spawn cron enabled. Setting to skip spawn_cron() call.');
$spawn_cron = false;
}
pb_backupbuddy::status('details', 'Scheduling Cron for `' . $this->_backup['serial'] . '`.');
// Need to make sure the database connection is active. Sometimes it goes away during long bouts doing other things -- sigh.
// This is not essential so use include and not require (suppress any warning)
@(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
if (class_exists('pluginbuddy_wpdbutils')) {
global $wpdb;
$dbhelper = new pluginbuddy_wpdbutils($wpdb);
if (!$dbhelper->kick()) {
pb_backupbuddy::status('error', __('Database Server has gone away, unable to schedule next backup step. The backup cannot continue. This is most often caused by mysql running out of memory or timing out far too early. Please contact your host.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('haltScript', '');
// Halt JS on page.
return false;
}
} else {
pb_backupbuddy::status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy'));
}
// Schedule event.
$cron_time = time() + $future_offset;
$cron_tag = pb_backupbuddy::cron_tag('process_backup');
$cron_args = array($this->_backup['serial']);
pb_backupbuddy::status('details', 'Scheduling next step to run at `' . $cron_time . '` (localized time: ' . pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($cron_time)) . ') with cron tag `' . $cron_tag . '` and serial arguments `' . implode(',', $cron_args) . '`.');
$schedule_result = backupbuddy_core::schedule_single_event($cron_time, $cron_tag, $cron_args);
if ($schedule_result === false) {
pb_backupbuddy::status('error', 'Unable to schedule next cron step. Verify that another plugin is not preventing / conflicting.');
} else {
pb_backupbuddy::status('details', 'Next step scheduled.');
pb_backupbuddy::status('startAction', 'cronPass');
pb_backupbuddy::status('cronParams', base64_encode(json_encode(array('time' => $cron_time, 'tag' => $cron_tag, 'args' => $cron_args))));
}
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
// Spawn cron.
if ($spawn_cron === true) {
pb_backupbuddy::status('details', 'Calling spawn_cron().');
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
} else {
pb_backupbuddy::status('details', 'Not calling spawn_cron().');
}
pb_backupbuddy::status('details', 'About to run next step. If the backup does not proceed within 15 seconds then something is interfering with the WordPress CRON system such as: server loopback issues, caching plugins, or scheduling plugins. Try disabling other plugins to see if it resolves issue. Check the Server Information page cron section to see if the next BackupBuddy step is scheduled to run. Enable "Classic" backup mode on the "Settings" page to rule out non-cron issues.');
return;
}
示例2: send
//.........这里部分代码省略.........
$done_url = $stash->get_upload_url($settings['_multipart_file'], 'done', $remote_path . $settings['_multipart_backup_type_dir'] . basename($settings['_multipart_file']));
pb_backupbuddy::status('details', 'Notifying Stash of completed multipart upload with done url `' . $done_url . '`.');
$request = new RequestCore($done_url);
$response = $request->send_request(true);
if (!$response->isOK()) {
$this_error = 'Error #756834682. Could not finalize Stash upload. Response code: `' . $response->get_response_code() . '`; Response body: `' . $response->get_response_body() . '`; Response headers: `' . $response->get_response_header() . '`.';
$pb_backupbuddy_destination_errors[] = $this_error;
pb_backupbuddy::status('error', $this_error);
return false;
} else {
// Good server response.
// See if we got an optional json response.
$upload_data = @json_decode($response->body, true);
if (isset($upload_data['error'])) {
$this_error = 'Stash error(s): `' . implode(' - ', $upload_data['error']) . '`.';
$pb_backupbuddy_destination_errors[] = $this_error;
pb_backupbuddy::status('error', $this_error);
return false;
}
pb_backupbuddy::status('details', 'Stash success sending file `' . basename($settings['_multipart_file']) . '`. File uploaded via multipart across `' . $this_part_number . '` parts and reported to Stash as completed.');
}
pb_backupbuddy::status('details', 'Stash has no more parts left for this multipart upload. Clearing multipart instance variables.');
$settings['_multipart_partnumber'] = 0;
$settings['_multipart_id'] = '';
$settings['_multipart_file'] = '';
$settings['_multipart_counts'] = array();
$settings['_multipart_upload_data'] = array();
}
delete_transient('pb_backupbuddy_stashquota_' . $settings['itxapi_username']);
// Delete quota transient since it probably has changed now.
// Schedule to continue if anything is left to upload for this multipart of any individual files.
if ($settings['_multipart_id'] != '' || count($files) > 0) {
pb_backupbuddy::status('details', 'Stash multipart upload has more parts left. Scheduling next part send.');
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('destination_send'), array($settings, $files, 'multipart', false));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
pb_backupbuddy::status('details', 'Stash scheduled send of next part(s). Done for this cycle.');
return array($settings['_multipart_id'], 'Sent ' . $this_part_number . ' of ' . count($multipart_destination_settings['_multipart_counts'] . ' parts.'));
}
}
// Upload each file.
foreach ($files as $file_id => $file) {
// Determine backup type directory (if zip).
$backup_type_dir = '';
$backup_type = '';
if (stristr($file, '.zip') !== false) {
// If a zip try to determine backup type.
pb_backupbuddy::status('details', 'Stash: Zip file. Detecting backup type if possible.');
$serial = pb_backupbuddy::$classes['core']->get_serial_from_file($file);
if (isset(pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'])) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `' . pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'] . '` via integrity check data.');
$backup_type_dir = pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'] . '/';
$backup_type = pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'];
} else {
if (stristr($file, '-db-') !== false) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `db` via filename.');
$backup_type_dir = 'db/';
$backup_type = 'db';
} elseif (stristr($file, '-full-') !== false) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `full` via filename.');
$backup_type_dir = 'full/';
$backup_type = 'full';
} else {
pb_backupbuddy::status('details', 'Stash: Could not detect backup type via integrity details nor filename.');
示例3: send
public static function send($settings = array(), $files = array(), $send_id = '', $delete_remote_after = false)
{
self::$_timeStart = microtime(true);
$settings = self::_normalizeSettings($settings);
if (false === ($settings = self::_connect($settings))) {
$error = 'Unable to connect with Google Drive. See log for details.';
echo $error;
pb_backupbuddy::status('error', $error);
return false;
}
$chunkSizeBytes = $settings['max_burst'] * 1024 * 1024;
// Send X mb at a time to limit memory usage.
foreach ($files as $file) {
$fileSize = filesize($file);
$fileinfo = pathinfo($file);
$fileextension = $fileinfo['extension'];
if ('zip' == $fileextension) {
$mimeType = 'application/zip';
} elseif ('php' == $fileextension) {
$mimeType = 'application/x-httpd-php';
} else {
$mimeType = '';
}
pb_backupbuddy::status('details', 'About to upload file `' . $file . '` of size `' . $fileSize . '` with mimetype `' . $mimeType . '`. Internal chunk size of `' . $chunkSizeBytes . '` bytes.');
//Insert a file
$driveFile = new Google_Service_Drive_DriveFile();
$driveFile->setTitle(basename($file));
$driveFile->setDescription('BackupBuddy file');
$driveFile->setMimeType($mimeType);
self::$_client->setDefer(true);
try {
$insertRequest = self::$_drive->files->insert($driveFile);
} catch (Exception $e) {
pb_backupbuddy::alert('Error #3232783268336: initiating upload. Details: ' . $e->getMessage());
return;
}
// See https://developers.google.com/api-client-library/php/guide/media_upload
try {
$media = new Google_Http_MediaFileUpload(self::$_client, $insertRequest, $mimeType, null, true, $chunkSizeBytes);
} catch (Exception $e) {
pb_backupbuddy::alert('Error #3893273937: initiating upload. Details: ' . $e->getMessage());
return;
}
$media->setFileSize($fileSize);
pb_backupbuddy::status('details', 'Opening file for sending in binary mode.');
$fs = fopen($file, 'rb');
// If chunked resuming then seek to the correct place in the file.
if ('' != $settings['resume_point'] && $settings['resume_point'] > 0) {
// Resuming send of a partially transferred file.
if (0 !== fseek($fs, $settings['resume_point'])) {
// Returns 0 on success.
pb_backupbuddy::status('error', 'Error #3872733: Failed to seek file to resume point `' . $settings['resume_point'] . '` via fseek().');
return false;
}
$prevPointer = $settings['resume_point'];
} else {
// New file send.
$prevPointer = 0;
}
$needProcessChunking = false;
// Set true if we need to spawn off resuming to a new PHP page load.
$uploadStatus = false;
while (!$uploadStatus && !feof($fs)) {
$chunk = fread($fs, $chunkSizeBytes);
$uploadStatus = $media->nextChunk($chunk);
// Handle splitting up across multiple PHP page loads if needed.
if (!feof($fs) && 0 != $settings['max_time']) {
// More data remains so see if we need to consider chunking to a new PHP process.
// If we are within X second of reaching maximum PHP runtime then stop here so that it can be picked up in another PHP process...
if (microtime(true) - self::$_timeStart + self::TIME_WIGGLE_ROOM >= $settings['max_time']) {
pb_backupbuddy::status('message', 'Approaching limit of available PHP chunking time of `' . $settings['max_time'] . '` sec. Ran for ' . round(microtime(true) - self::$_timeStart, 3) . ' sec. Proceeding to use chunking.');
@fclose($fs);
// Tells next chunk where to pick up.
$settings['resume_point'] = $prevPointer;
if (isset($chunksTotal)) {
$settings['chunks_total'] = $chunksTotal;
}
// Schedule cron.
$cronTime = time();
$cronArgs = array($settings, $files, $send_id, $delete_after = false);
$cronHashID = md5($cronTime . serialize($cronArgs));
$cronArgs[] = $cronHashID;
$schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
if (true === $schedule_result) {
pb_backupbuddy::status('details', 'Next Site chunk step cron event scheduled.');
} else {
pb_backupbuddy::status('error', 'Next Site chunk step cron even FAILED to be scheduled.');
}
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
return array($prevPointer, 'Sent part ' . $settings['chunks_sent'] . ' of ~' . $settings['chunks_total'] . ' parts.');
// filepointer location, elapsed time during the import
} else {
// End if.
pb_backupbuddy::status('details', 'Not approaching time limit.');
}
} else {
pb_backupbuddy::status('details', 'No more data remains (eg for chunking) so finishing up.');
//.........这里部分代码省略.........
示例4: remote_send
public function remote_send()
{
if (defined('PB_DEMO_MODE')) {
die('Access denied in demo mode.');
}
$success_output = false;
// Set to true onece a leading 1 has been sent to the javascript to indicate success.
$destination_id = pb_backupbuddy::_POST('destination_id');
if (pb_backupbuddy::_POST('file') != 'importbuddy.php') {
$backup_file = pb_backupbuddy::$options['backup_directory'] . pb_backupbuddy::_POST('file');
} else {
$backup_file = '';
}
if (pb_backupbuddy::_POST('send_importbuddy') == '1') {
$send_importbuddy = true;
pb_backupbuddy::status('details', 'Cron send to be scheduled with importbuddy sending.');
} else {
$send_importbuddy = false;
pb_backupbuddy::status('details', 'Cron send to be scheduled WITHOUT importbuddy sending.');
}
// For Stash we will check the quota prior to initiating send.
if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') {
// Pass off to destination handler.
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$send_result = pb_backupbuddy_destinations::get_info('stash');
// Used to kick the Stash destination into life.
$stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true);
//print_r( $stash_quota );
if ($backup_file != '') {
$backup_file_size = filesize($backup_file);
} else {
$backip_file_size = 50000;
}
if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) {
echo "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage or delete files to make space.\n\n";
echo 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. ';
echo 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).';
die;
} else {
if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') {
echo '1Warning: ' . $stash_quota['quota_warning'] . "\n\n";
$success_output = true;
}
}
}
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('remote_send'), array($destination_id, $backup_file, pb_backupbuddy::_POST('trigger'), $send_importbuddy));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
// SEE cron.php remote_send() for sending function that we pass to via the cron above.
if ($success_output === false) {
echo 1;
}
die;
}
示例5: print_r
if ('' != pb_backupbuddy::_GET('downloadlink_file')) {
$fileMeta = pb_backupbuddy_destination_gdrive::getFileMeta($settings, pb_backupbuddy::_GET('downloadlink_file'));
pb_backupbuddy::alert('<a href="' . $fileMeta->alternateLink . '" target="_new">Click here</a> to view & download this file from Google Drive. You must log in to Google to access it.');
}
// Copy file to local
if ('' != pb_backupbuddy::_GET('cpy_file')) {
$destinationFile = $fileMeta = pb_backupbuddy_destination_gdrive::getFileMeta($settings, pb_backupbuddy::_GET('cpy_file'));
/*
echo '<pre>';
print_r( $fileMeta );
echo '</pre>';
*/
pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
echo '<br>';
pb_backupbuddy::status('details', 'Scheduling Cron for creating Google Drive copy.');
backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_destination_copy'), array($destination, $fileMeta->originalFilename, pb_backupbuddy::_GET('cpy_file')));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
}
?>
<span id="backupbuddy_gdrive_loading"><h3><img src="<?php
echo pb_backupbuddy::plugin_url();
?>
/images/loading.gif" alt="' . __('Loading...', 'it-l10n-backupbuddy' ) . '" title="' . __('Loading...', 'it-l10n-backupbuddy' ) . '" width="16" height="16" style="vertical-align: -3px;"> <?php
_e('Loading...', 'it-l10n-backupbuddy');
?>
</h3></span>
示例6: implode
pb_backupbuddy::alert('Error: Unable to delete `' . $item . '`. Verify permissions.');
}
}
if (count($deleted_files) > 0) {
pb_backupbuddy::alert('Deleted ' . implode(', ', $deleted_files) . '.');
delete_transient('pb_backupbuddy_stashquota_' . $itxapi_username);
// Delete quota transient since it probably has changed now.
}
echo '<br>';
}
// Handle copying files to local
if (pb_backupbuddy::_GET('cpy_file') != '') {
pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
echo '<br>';
pb_backupbuddy::status('details', 'Scheduling Cron for creating Stash copy.');
backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_remote_copy'), array('stash', pb_backupbuddy::_GET('cpy_file'), $settings));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
}
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
$link = $s3->get_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . pb_backupbuddy::_GET('downloadlink_file'), array('preauth' => time() + 3600));
pb_backupbuddy::alert('You may download this backup (' . pb_backupbuddy::_GET('downloadlink_file') . ') with <a href="' . $link . '">this link</a>. The link is valid for one hour.');
echo '<br>';
}
// QUOTA INFORMATION.
$account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $itxapi_username, 'itxapi_password' => $itxapi_password), false);
/*
echo '<pre>';
示例7: remoteSendRetry
public static function remoteSendRetry(&$fileoptions_obj, $send_id, $maximumRetries = 1)
{
// Destination settings are stored for this destination so see if we can retry sending it (if settings permit).
if (isset($fileoptions_obj->options['destinationSettings']) && count($fileoptions_obj->options['destinationSettings']) > 0) {
/*
echo '<pre>';
print_r( $fileoptions_obj->options );
echo '</pre>';
*/
$destination_settings = $fileoptions_obj->options['destinationSettings'];
// these are the latest; includes info needed for chunking too.
//$send_id = $fileoptions_obj->options['sendID'];
$delete_after = $fileoptions_obj->options['deleteAfter'];
$retries = $fileoptions_obj->options['retries'];
$file = $fileoptions_obj->options['file'];
if ($retries < $maximumRetries) {
pb_backupbuddy::status('details', 'Timed out remote send has not exceeded retry limit (`' . $maximumRetries . '`). Trying to send again.');
//$fileoptions_obj->options['retries']++;
//$fileoptions_obj->save(); // NOTE: Retry count now updates in bootstrap.php send() function. Only leaving this here temporarily to help get rid of failed resends from accumulating with old format.
// Schedule send of this piece.
pb_backupbuddy::status('details', 'Scheduling cron to send to this remote destination...');
$cronArgs = array($destination_settings, $file, $send_id, $delete_after, $identifier = '', $isRetry = true);
/*
echo 'cronargs: ';
echo '<pre>';
print_r( $cronArgs );
echo '</pre>';
*/
$schedule_result = backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
if ($schedule_result === FALSE) {
$error = 'Error scheduling file transfer. Please check your BackupBuddy error log for details. A plugin may have prevented scheduling or the database rejected it.';
pb_backupbuddy::status('error', $error);
echo $error;
} else {
pb_backupbuddy::status('details', 'Cron to send to remote destination scheduled.');
}
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
return true;
} else {
pb_backupbuddy::status('details', 'Maximum remote send timeout retries (`' . $maximumRetries . '`) passed to function met. Not resending.');
return false;
}
}
}
示例8: array
}
if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) {
echo "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage or delete files to make space.\n\n";
echo 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. ';
echo 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).';
die;
} else {
if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') {
echo '1Warning: ' . $stash_quota['quota_warning'] . "\n\n";
$success_output = true;
}
}
}
// end if Stash.
pb_backupbuddy::status('details', 'Scheduling cron to send to this remote destination...');
$schedule_result = backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('remote_send'), array($destination_id, $backup_file, pb_backupbuddy::_POST('trigger'), $send_importbuddy, $delete_after));
if ($schedule_result === FALSE) {
$error = 'Error scheduling file transfer. Please check your BackupBuddy error log for details. A plugin may have prevented scheduling or the database rejected it.';
pb_backupbuddy::status('error', $error);
echo $error;
} else {
pb_backupbuddy::status('details', 'Cron to send to remote destination scheduled.');
}
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
// SEE cron.php remote_send() for sending function that we pass to via the cron above.
if ($success_output === false) {
echo 1;
}
示例9: send
//.........这里部分代码省略.........
pb_backupbuddy::status('error', $this_error);
return false;
} else {
pb_backupbuddy::status('details', 'S3 notified S3 of multipart completion.');
}
pb_backupbuddy::status('details', 'S3 has no more parts left for this multipart upload. Clearing multipart instance variables.');
$settings['_multipart_partnumber'] = 0;
$settings['_multipart_id'] = '';
$settings['_multipart_file'] = '';
$settings['_multipart_remotefile'] = '';
// Multipart completed so safe to prevent housekeeping of incomplete multipart uploads.
$settings['_multipart_transferspeeds'][] = $uploaded_speed;
// Overall upload speed average.
$uploaded_speed = array_sum($settings['_multipart_transferspeeds']) / count($settings['_multipart_counts']);
pb_backupbuddy::status('details', 'Upload speed average of all chunks: `' . pb_backupbuddy::$format->file_size($uploaded_speed) . '`.');
$settings['_multipart_counts'] = array();
// Update stats.
$fileoptions['_multipart_status'] = $update_status;
$fileoptions['finish_time'] = time();
$fileoptions['status'] = 'success';
if (isset($uploaded_speed)) {
$fileoptions['write_speed'] = $uploaded_speed;
}
$fileoptions_obj->save();
unset($fileoptions);
}
// Schedule to continue if anything is left to upload for this multipart of any individual files.
if ($settings['_multipart_id'] != '' || count($files) > 0) {
pb_backupbuddy::status('details', 'S3 multipart upload has more parts left. Scheduling next part send.');
$cronTime = time();
$cronArgs = array($settings, $files, $send_id, $delete_after);
$cronHashID = md5($cronTime . serialize($cronArgs));
$cronArgs[] = $cronHashID;
$schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
if (true === $schedule_result) {
pb_backupbuddy::status('details', 'Next S3 chunk step cron event scheduled.');
} else {
pb_backupbuddy::status('error', 'Next S3 chunk step cron even FAILED to be scheduled.');
}
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
return array($settings['_multipart_id'], 'Sent part ' . $this_part_number . ' of ' . count($settings['_multipart_counts']) . ' parts.');
}
}
// end if multipart continuation.
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
// Upload each file.
foreach ($files as $file_id => $file) {
// Determine backup type directory (if zip).
$backup_type_dir = '';
$backup_type = '';
if (stristr($file, '.zip') !== false) {
// If a zip try to determine backup type.
pb_backupbuddy::status('details', 'S3: Zip file. Detecting backup type if possible.');
$serial = backupbuddy_core::get_serial_from_file($file);
// See if we can get backup type from fileoptions data.
pb_backupbuddy::status('details', 'Fileoptions instance #9.');
$backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = true, $ignore_lock = true);
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::status('error', 'Unable to open fileoptions file `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' . '`.');
} else {
if (isset($backup_options->options['integrity']['detected_type'])) {
pb_backupbuddy::status('details', 'S3: Detected backup type as `' . $backup_options->options['integrity']['detected_type'] . '` via integrity check data.');
//$backup_type_dir = $backup_options->options['integrity']['detected_type'] . '/';
示例10: foreach
// loop through and delete s3 files
foreach ($_POST['files'] as $s3file) {
$delete_count++;
// Delete S3 file
$s3->deleteObject($aws_bucket, $s3file);
}
}
if ($delete_count > 0) {
pb_backupbuddy::alert(sprintf(_n('Deleted %d file.', 'Deleted %d files.', $delete_count, 'it-l10n-backupbuddy'), $delete_count));
}
}
// Copy S3 backups to the local backup files
if (!empty($_GET['copy_file'])) {
pb_backupbuddy::alert(sprintf(_x('The remote file is now being copied to your %1$slocal backups%2$s', '%1$s and %2$s are open and close <a> tags', 'it-l10n-backupbuddy'), '<a href="' . pb_backupbuddy::page_url() . '">', '</a>.'));
pb_backupbuddy::status('details', 'Scheduling Cron for creating s3 copy.');
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('process_s3_copy'), array($_GET['copy_file'], $aws_accesskey, $aws_secretkey, $aws_bucket, $aws_directory));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
}
echo '<h3>', __('Viewing', 'it-l10n-backupbuddy'), ' `' . $destination['title'] . '` (' . $destination['type'] . ')</h3>';
?>
<div style="max-width: 950px;">
<form id="posts-filter" enctype="multipart/form-data" method="post" action="<?php
echo pb_backupbuddy::page_url() . '&custom=' . $_GET['custom'] . '&destination_id=' . $_GET['destination_id'];
?>
">
<div class="tablenav">
<div class="alignleft actions">
<input type="submit" name="delete_file" value="<?php
示例11: post_backup
function post_backup()
{
pb_backupbuddy::status('message', __('Cleaning up after backup.', 'it-l10n-backupbuddy'));
// Delete temporary data directory.
if (file_exists($this->_backup['temp_directory'])) {
pb_backupbuddy::status('details', __('Removing temp data directory.', 'it-l10n-backupbuddy'));
pb_backupbuddy::$filesystem->unlink_recursive($this->_backup['temp_directory']);
}
// Delete temporary ZIP directory.
if (file_exists(pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . $this->_backup['serial'] . '/')) {
pb_backupbuddy::status('details', __('Removing temp zip directory.', 'it-l10n-backupbuddy'));
pb_backupbuddy::$filesystem->unlink_recursive(pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . $this->_backup['serial'] . '/');
}
$this->trim_old_archives();
// Clean up any old excess archives pushing us over defined limits in settings.
$message = __('completed successfully in ', 'it-l10n-backupbuddy') . pb_backupbuddy::$format->time_duration(time() - $this->_backup['start_time']) . '. File: ' . basename($this->_backup['archive_file']);
if ($this->_backup['trigger'] == 'manual') {
// No more manual notifications. Removed Feb 2012 before 3.0.
} elseif ($this->_backup['trigger'] == 'scheduled') {
// Load core if it has not been instantiated yet.
if (!isset(pb_backupbuddy::$classes['core'])) {
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
}
pb_backupbuddy::status('details', __('Sending scheduled backup complete email notification.', 'it-l10n-backupbuddy'));
pb_backupbuddy::$classes['core']->mail_notify_scheduled('complete', __('Scheduled backup', 'it-l10n-backupbuddy') . ' (' . $this->_backup['schedule_title'] . ') ' . $message);
} else {
pb_backupbuddy::status('error', 'Error #4343434. Unknown backup trigger.');
}
// Schedule cleanup (12 hours from now; time for remote transfers) of log status file and data structure.
wp_schedule_single_event(time() + 12 * 60 * 60, pb_backupbuddy::cron_tag('final_cleanup'), array($this->_backup['serial']));
pb_backupbuddy::status('message', __('Finished cleaning up.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('action', 'archive_url^' . pb_backupbuddy::ajax_url('download_archive') . '&backupbuddy_backup=' . basename($this->_backup['archive_file']));
if ($this->_backup['backup_mode'] == '1') {
$stats = stat($this->_backup['archive_file']);
pb_backupbuddy::status('details', __('Final ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']));
pb_backupbuddy::status('action', 'archive_size^' . pb_backupbuddy::$format->file_size($stats['size']));
}
pb_backupbuddy::status('message', __('Backup completed successfully in', 'it-l10n-backupbuddy') . ' ' . pb_backupbuddy::$format->time_duration(time() - $this->_backup['start_time']) . '. ' . __('Done.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('action', 'finish_backup');
return true;
}
示例12: ftp_close
// close this connection
ftp_close($conn_id);
}
if ($delete_count > 0) {
pb_backupbuddy::alert(sprintf(_n('Deleted %d file.', 'Deleted %d files.', $delete_count, 'it-l10n-backupbuddy'), $delete_count));
} else {
pb_backupbuddy::alert(__('No backups were deleted.', 'it-l10n-backupbuddy'));
}
echo '<br>';
}
// Copy ftp backups to the local backup files
if (!empty($_GET['cpy_file'])) {
pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
echo '<br>';
pb_backupbuddy::status('details', 'Scheduling Cron for creating ftp copy.');
backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_ftp_copy'), array($_GET['cpy_file'], $ftp_server, $ftp_username, $ftp_password, $ftp_directory, $port, $ftps));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
}
// Connect to server
if ($ftps == '1') {
// Connect with FTPs.
if (function_exists('ftp_ssl_connect')) {
$conn_id = ftp_ssl_connect($ftp_server, $port);
if ($conn_id === false) {
pb_backupbuddy::status('details', 'Unable to connect to FTPS `' . $ftp_server . '` on port `' . $port . '` (check address/FTPS support and that server can connect to this address via this port).', 'error');
return false;
} else {
pb_backupbuddy::status('details', 'Connected to FTPs.');
示例13: send
//.........这里部分代码省略.........
pb_backupbuddy::status('details', 'Max time not set in settings so detecting server max PHP runtime.');
$maxTime = backupbuddy_core::detectMaxExecutionTime();
}
//return;
// Handle splitting up across multiple PHP page loads if needed.
if (!feof($fs) && 0 != $maxTime) {
// More data remains so see if we need to consider chunking to a new PHP process.
// If we are within X second of reaching maximum PHP runtime then stop here so that it can be picked up in another PHP process...
$totalSizeSent = self::$_chunksSentThisRound * $chunkSizeBytes;
// Total bytes sent this PHP load.
$bytesPerSec = $totalSizeSent / (microtime(true) - self::$_timeStart);
$timeRemaining = $maxTime - (microtime(true) - self::$_timeStart + self::TIME_WIGGLE_ROOM);
if ($timeRemaining < 0) {
$timeRemaining = 0;
}
$bytesWeCouldSendWithTimeLeft = $bytesPerSec * $timeRemaining;
pb_backupbuddy::status('details', 'Total sent: `' . pb_backupbuddy::$format->file_size($totalSizeSent) . '`. Speed (per sec): `' . pb_backupbuddy::$format->file_size($bytesPerSec) . '`. Time Remaining (w/ wiggle): `' . $timeRemaining . '`. Size that could potentially be sent with remaining time: `' . pb_backupbuddy::$format->file_size($bytesWeCouldSendWithTimeLeft) . '` with chunk size of `' . pb_backupbuddy::$format->file_size($chunkSizeBytes) . '`.');
if ($bytesWeCouldSendWithTimeLeft < $chunkSizeBytes) {
// We can send more than a whole chunk (including wiggle room) so send another bit.
pb_backupbuddy::status('message', 'Not enough time left (~`' . $timeRemaining . '`) with max time of `' . $maxTime . '` sec to send another chunk at `' . pb_backupbuddy::$format->file_size($bytesPerSec) . '` / sec. Ran for ' . round(microtime(true) - self::$_timeStart, 3) . ' sec. Proceeding to use chunking.');
@fclose($fs);
// Tells next chunk where to pick up.
if (isset($chunksTotal)) {
$settings['_chunks_total'] = $chunksTotal;
}
// Grab these vars from the class. Note that we changed these vars from private to public to make chunked resuming possible.
$settings['_media_resumeUri'] = $media->resumeUri;
$settings['_media_progress'] = $media->progress;
// Schedule cron.
$cronTime = time();
$cronArgs = array($settings, $files, $send_id, $delete_after);
$cronHashID = md5($cronTime . serialize($cronArgs));
$cronArgs[] = $cronHashID;
$schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
if (true === $schedule_result) {
pb_backupbuddy::status('details', 'Next Site chunk step cron event scheduled.');
} else {
pb_backupbuddy::status('error', 'Next Site chunk step cron even FAILED to be scheduled.');
}
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
return array($prevPointer, 'Sent part ' . $settings['_chunks_sent'] . ' of ~' . $settings['_chunks_total'] . ' parts.');
// filepointer location, elapsed time during the import
} else {
// End if.
pb_backupbuddy::status('details', 'Not approaching limits.');
}
} else {
pb_backupbuddy::status('details', 'No more data remains (eg for chunking) so finishing up.');
if ('' != $send_id) {
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
if (true !== ($result = $fileoptions_obj->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034.397237. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$fileoptions =& $fileoptions_obj->options;
$fileoptions['_multipart_status'] = 'Sent part ' . $settings['_chunks_sent'] . ' of ~' . $settings['_chunks_total'] . ' parts.';
$fileoptions['finish_time'] = time();
$fileoptions['status'] = 'success';
$fileoptions_obj->save();
unset($fileoptions_obj);
}
示例14: array
$delete_count++;
// Delete Rackspace file
$container->delete_object($rsfile);
}
}
if ($delete_count > 0) {
pb_backupbuddy::alert(sprintf(_n('Deleted %d file', 'Deleted %d files', $delete_count, 'it-l10n-backupbuddy'), $delete_count));
}
echo '<br>';
}
// Copy Rackspace backup to the local backup files
if (!empty($_GET['cpy_file'])) {
pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
echo '<br>';
pb_backupbuddy::status('details', 'Scheduling Cron for creating Rackspace copy.');
backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_rackspace_copy'), array($_GET['cpy_file'], $rs_username, $rs_api_key, $rs_container, $rs_server));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
}
// List objects in container
/*
if ( $rs_path != '' ) {
$results = $container->get_objects( 0, NULL, 'backup-', $rs_path );
} else {
*/
$results = $container->get_objects(0, NULL, 'backup-');
/* } */
$urlPrefix = pb_backupbuddy::ajax_url('remoteClient') . '&destination_id=' . htmlentities(pb_backupbuddy::_GET('destination_id'));
?>
示例15: wp_schedule_single_event
$delete_count++;
// Delete dropbox file
$dropbuddy->delete($dropboxfile);
}
}
if ($delete_count > 0) {
pb_backupbuddy::alert(sprintf(_n('Deleted %d file', 'Deleted %d files', $delete_count, 'it-l10n-backupbuddy'), $delete_count));
$meta_data = $dropbuddy->get_meta_data($destination['directory']);
// Refresh listing.
}
}
// Copy dropbox backups to the local backup files
if (!empty($_GET['copy_file'])) {
pb_backupbuddy::alert(sprintf(_x('The remote file is now being copied to your %1$slocal backups%2$s', '%1$s and %2$s are open and close <a> tags', 'it-l10n-backupbuddy'), '<a href="' . pb_backupbuddy::page_url() . '">', '</a>. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.'));
pb_backupbuddy::status('details', 'Scheduling Cron for creating Dropbox copy.');
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('process_dropbox_copy'), array($_GET['destination_id'], $_GET['copy_file']));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
}
echo '<h3>', __('Viewing', 'it-l10n-backupbuddy'), ' `' . $destination['title'] . '` (' . $destination['type'] . ')</h3>';
?>
<div style="max-width: 950px;">
<form id="posts-filter" enctype="multipart/form-data" method="post" action="<?php
echo pb_backupbuddy::page_url() . '&custom=' . $_GET['custom'] . '&destination_id=' . $_GET['destination_id'];
?>
">
<div class="tablenav">
<div class="alignleft actions">