/** * * @return array array('fail'=>1/0 , 'consoleOutput' => array('text') ) */ public function createBackup() { $console = Api_Component_Factory::createConsole(); $console->exec("cd {$this->getBuildDir()} && sh pake create_dir"); $console->exec("cd {$this->getBuildDir()} && sh pake fix_permissions"); $console->exec("cd {$this->getBuildDir()} && sh pake write_cron_backuper"); $ret = $console->exec("cd {$this->getBuildDir()} && bash backup.sh ignore_schedule"); return array('fail' => $ret == 1, 'consoleOutput' => $console->getOutput(), 'lastBackup' => $this->getLastBackup()); }
static function _initLogger() { $routes = array(); $routes[] = Api_Component_Factory::createLogFileLogRoute(); $routes[] = Api_Component_Factory::createChatLogRoute(); $logger = Api_Component_Log_Logger::getInstance(); foreach ($routes as $route) { $logger->addRoute($route); } }
public function actionGetLast() { $domainName = filter_input(INPUT_GET, 'domain_name'); $response = Api_Component_Factory::createResponse(); if (!$this->isHaveAccessForDomain(self::GET_LAST_ACTION, $domainName, INPUT_GET)) { $response->setError(true)->setSuccess(false)->addMessage("access denied"); http_response_code(403); echo $this->renderView('json', array('data' => $response->getData())); Api_Core_Application::end(); } $helper = new Api_Application_Api_Helper_Backup(); $storage = Api_Component_Factory::createFileStorage(); $files = $helper->getLastFileUrl($domainName, $storage); $lastFile = end($files); if (empty($lastFile)) { $response->setError(true)->setSuccess(false)->addMessage("file not found"); http_response_code(404); echo $this->renderView('json', array('data' => $response->getData())); } else { $url = $storage->getFileUrl($lastFile["file"]); 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 * 50); if ($fd = fopen($url, 'r')) { while (!feof($fd)) { print fread($fd, 1024); } fclose($fd); } $storage->closeFileUrl($lastFile["file"]); Api_Core_Application::end(); } }
<?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); }
/** * * @param string $domainName * @return \Job_Backup_Storage */ static function createStorage($domainName) { $config = Api_Core_Factory::createConfig()->getConfig(); $storage = Api_Component_Factory::createFileStorage(); return new Job_Backup_Storage($domainName, $storage); }
static function createWorkerStarter() { $jobServer = Api_Component_Factory::createJobServer(); $config = Api_Core_Factory::createConfig()->getConfig(); return new Job_Monitor_WorkerStarter($jobServer, $config['host']['workers']); }
public function __construct($params = null) { $this->_params = $params; $this->_hipChat = Api_Component_Factory::createHipChat(); }