/** * @param $job GearmanJob */ function run_backup($job) { global $root; echo "Registering {$job->workload()}"; $domainName = trim($job->workload()); try { $backup = new Job_Backup($domainName); echo "starting {$domainName} \n"; $result = $backup->run(); echo "result {$domainName} \n"; return $result; } catch (Exception $ex) { Api_Core_Application::log("Ошибка в выполнении задачи " . $ex->getMessage(), array('domainName' => $domainName), Api_Component_Log_Logger::LEVEL_ERROR); } }
<?php ini_set('display_errors', 1); error_reporting(E_ALL); $root = realpath(__DIR__); require_once $root . '/autoload.php'; set_time_limit(0); ignore_user_abort(true); $configData = (include $root . '/configs/config.php'); Api_Core_Application::init($configData); $backup = new Job_Backup('dev1vika1'); $backup->run(); die; $amazon = Api_Component_Factory::createFileStorage(); $files = $amazon->getFiles('**/2016.03.04'); $lastFile = end($files); if (!empty($lastFile)) { $url = $amazon->getFileUrl($lastFile["file"]); //var_dump($url, basename($url), basename($lastFile["file"])); die(); if (ob_get_level()) { ob_end_clean(); } header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($lastFile["file"]) . '"'); header('Content-transfer-encoding: binary'); // Required? Not sure.. set_time_limit(60 * 28); if ($fd = fopen($url, 'r')) { while (!feof($fd)) { print fread($fd, 1024); }