public static function no_recent_backup_reminder() { // If Live enabled, see if too long since the last Snapshot. foreach (pb_backupbuddy::$options['remote_destinations'] as $destination) { // Look for Live destination. if ('live' == $destination['type'] && (int) $destination['no_new_snapshots_error_days'] > 0) { // Live destination and notifications are enabled. require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; $state = backupbuddy_live_periodic::get_stats(); if ($state['stats']['last_db_snapshot'] > 0) { // At least one Snapshot has been made. $time_since_last = time() - $state['stats']['last_db_snapshot']; $days_since_last = round($time_since_last / 60 / 60 / 24); if ($days_since_last > (int) $destination['no_new_snapshots_error_days']) { $message = 'Warning! BackupBuddy is configured to notify you if no new BackupBuddy Stash Live Snapshots have been made in `' . (int) $destination['no_new_snapshots_error_days'] . '` days. It has been `' . $days_since_last . '` days since your last Snapshot. There may be a problem with your site\'s Stash Live setup requiring your attention.'; pb_backupbuddy::status('warning', $message); backupbuddy_core::mail_error($message); } } elseif ($state['stats']['first_activity'] > 0) { // Live was set up but never even made a first Snapshot. Activate if DOUBLE the no_new_snapshot_error_days is surpassed (to give time for first backup to fully upload). $time_since_last = time() - $state['stats']['first_activity']; $days_since_last = round($time_since_last / 60 / 60 / 24); if ($days_since_last > (int) $destination['no_new_snapshots_error_days'] * 2) { $message = 'Warning! BackupBuddy is configured to notify you if no new BackupBuddy Stash Live Snapshots have been made in `' . (int) $destination['no_new_snapshots_error_days'] . '` days. It has been at least twice this (`' . $days_since_last . '` days) since you set up BackupBuddy Stash Live but the first Snapshot has not been made yet. There may be a problem with your site\'s Stash Live setup requiring your attention.'; pb_backupbuddy::status('warning', $message); backupbuddy_core::mail_error($message); } } return true; // Don't send any traditional notifications when Live enabled. } } // Alert user if no new backups FINISHED within X number of days if enabled. Max 1 email notification per 24 hours period. if (is_main_site()) { // Only run for main site or standalone. if (pb_backupbuddy::$options['no_new_backups_error_days'] > 0) { if (pb_backupbuddy::$options['last_backup_finish'] > 0) { $time_since_last = time() - pb_backupbuddy::$options['last_backup_finish']; $days_since_last = round($time_since_last / 60 / 60 / 24); if ($days_since_last > pb_backupbuddy::$options['no_new_backups_error_days']) { $last_sent = get_transient('pb_backupbuddy_no_new_backup_error'); if (false === $last_sent) { $last_sent = time(); set_transient('pb_backupbuddy_no_new_backup_error', $last_sent, 60 * 60 * 24); } if (time() - $last_sent > 60 * 60 * 24) { // 24hrs+ elapsed since last email sent. $message = 'Warning! BackupBuddy is configured to notify you if no new backups have completed in `' . pb_backupbuddy::$options['no_new_backups_error_days'] . '` days. It has been `' . $days_since_last . '` days since your last completed backup.'; pb_backupbuddy::status('warning', $message); backupbuddy_core::mail_error($message); } } } } } }
<?php // Incoming vars: -NONE- require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; if (false === ($destination_id = backupbuddy_live::getLiveID())) { // $destination_id used by _stats.php. return false; } require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; $state = backupbuddy_live_periodic::get_stats(); // If currently running. if ('daily_init' != $state['step']['function'] && time() - $state['stats']['last_activity'] < backupbuddy_core::adjustedMaxExecutionTime()) { set_transient('backupbuddy_live_snapshot', true, 60 * 60 * 48); // Request transient to run. pb_backupbuddy::status('details', 'Snapshot requested to be ran.'); if ('1' != pb_backupbuddy::$options['skip_spawn_cron_call']) { pb_backupbuddy::status('details', 'Spawning cron now.'); update_option('_transient_doing_cron', 0); // Prevent cron-blocking for next item. spawn_cron(time() + 150); // Adds > 60 seconds to get around once per minute cron running limit. } } else { backupbuddy_live_periodic::_set_next_step('daily_init', array($manual_snapshot = true), $save_now_and_unlock = true); $schedule_result = backupbuddy_core::schedule_single_event(time(), 'live_periodic', $cronArgs = array()); if (true === $schedule_result) { pb_backupbuddy::status('details', 'Next Live Periodic chunk step cron event scheduled.'); } else { pb_backupbuddy::status('error', 'Next Live Periodic chunk step cron event FAILED to be scheduled.'); } if ('1' != pb_backupbuddy::$options['skip_spawn_cron_call']) {