public static function _step_wait_on_transfers() { $sleep_time = 10; if (false === self::_load_state()) { pb_backupbuddy::status('warning', 'Warning #4383434043: _step_wait_on_transfers() could not load state.'); return false; } if (self::$_state['stats']['files_pending_send'] > 0 || self::$_state['stats']['tables_pending_send'] > 0) { if (0 == self::$_state['stats']['wait_on_transfers_start']) { self::$_state['stats']['wait_on_transfers_start'] = microtime(true); // Make sure timestamp set to prevent infinite loop. self::$_stateObj->save(); } $destination_settings = self::get_destination_settings(); if (time() - self::$_state['stats']['wait_on_transfers_start'] > $destination_settings['max_wait_on_transfers_time'] * 60) { pb_backupbuddy::status('warning', 'Ran out of max time (`' . round((time() - self::$_state['stats']['wait_on_transfers_start']) / 60) . '` of `' . $destination_settings['max_wait_on_transfers_time'] . '` max mins) waiting for pending transfers to finish. Giving up until next periodic restart.'); return false; } pb_backupbuddy::status('details', 'Sleeping for `' . $sleep_time . '` secs to wait on `' . self::$_state['stats']['files_pending_send'] . '` file and `' . self::$_state['stats']['tables_pending_send'] . '` database table transfers. Closing state.'); self::$_stateObj = ''; // Close stateObj so sleeping won't hinder other operations. sleep($sleep_time); // Re-open state. if (false === self::_load_state()) { return false; } if (!is_numeric(self::$_state['stats']['files_pending_send']) || !is_numeric(self::$_state['stats']['tables_pending_send'])) { pb_backupbuddy::status('error', 'Error #83989484: files_pending_send or tables_pending_send missing numeric value. State details: `' . print_r(self::$_state, true) . '`.'); } pb_backupbuddy::status('details', '`' . self::$_state['stats']['files_pending_send'] . '` files and `' . self::$_state['stats']['tables_pending_send'] . '` database tables are still pending transfer after sleeping. Waiting for transfers to finish before creating Snapshot (`' . round((time() - self::$_state['stats']['wait_on_transfers_start']) / 60) . '` of `' . $destination_settings['max_wait_on_transfers_time'] . '` max mins elapsed).'); $waitingListLimit = 5; // Show some of the files pending send for troubleshooting. if (self::$_state['stats']['files_pending_send'] > 0) { if (false !== self::_load_catalog()) { $waitingFileList = array(); foreach (self::$_catalog as $catalogFilename => $catalogFile) { if (0 == $catalogFile['b']) { // Not yet transferred. $waitingFileList[] = $catalogFilename . ' (' . $catalogFile['t'] . ' send tries)'; } if (count($waitingFileList) > $waitingListLimit) { break; } } if (count($waitingFileList) > 0) { pb_backupbuddy::status('details', 'List of up to `' . $waitingListLimit . '` of `' . self::$_state['stats']['files_pending_send'] . '` pending file sends: ' . implode('; ', $waitingFileList)); $files_pending_send_file = backupbuddy_core::getLogDirectory() . 'live/files_pending_send-' . pb_backupbuddy::$options['log_serial'] . '.txt'; if (false === @file_put_contents($files_pending_send_file, implode("\n", $waitingFileList))) { // Unable to write. } } } else { pb_backupbuddy::status('details', 'Catalog not ready for preview of pending file list. Skipping.'); } } // Show some of the tables pending send for troubleshooting. if (self::$_state['stats']['tables_pending_send'] > 0) { if (false !== self::_load_tables()) { $waitingTableList = array(); foreach (self::$_tables as $tableName => $table) { if (0 == $table['b']) { // Not yet transferred. $waitingTableList[] = $tableName . ' (' . $table['t'] . ' send tries)'; } if (count($waitingTableList) > $waitingListLimit) { break; } } if (count($waitingTableList) > 0) { pb_backupbuddy::status('details', 'List of up to `' . $waitingListLimit . '` of `' . self::$_state['stats']['tables_pending_send'] . '` pending table sends: ' . implode('; ', $waitingTableList)); $tables_pending_send_file = backupbuddy_core::getLogDirectory() . 'live/tables_pending_send-' . pb_backupbuddy::$options['log_serial'] . '.txt'; if (false === @file_put_contents($tables_pending_send_file, implode("\n", $waitingTableList))) { // Unable to write. } } } else { pb_backupbuddy::status('details', 'Table catalog not ready for preview of pending table list. Skipping.'); } } backupbuddy_live::queue_step($step = 'wait_on_transfers', $args = array(), $skip_run_now = true); return true; } // No more files are pending. Jumps back to snapshot. return true; }