public function action_restore() { $this->auto_render = FALSE; $file = $this->request->param('file'); $backup = Model_Backup::factory(BACKUP_PLUGIN_FOLDER . $file)->restore(); Kohana::$log->add(Log::INFO, ':user restore backup')->write(); Messages::success(__('Backup restored successfully')); $this->go_back(); }
protected function _execute(array $params) { if ($params['database'] > 0) { Model_Backup::factory($params['folder'] . 'db-' . date('YmdHis') . '.sql')->create()->save(); Minion_CLI::write(__('Database backup created successfully')); } if ($params['filesystem'] > 0) { if (Model_Backup::factory($params['folder'] . 'filesystem-' . date('YmdHis') . '.zip')->create()) { Minion_CLI::write(__('Filesystem backup created successfully')); } } }
/** * The index action * * @access public * @return void */ public function action_index() { $settings = \Config::load('backup.db'); if (\Input::post()) { $input = \Input::post(); if (!\Input::is_ajax()) { $val = Model_Backup::validate('create'); if (!$val->run()) { if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to create settings</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } else { try { \Config::save('backup.db', array('enable' => $input['enable'], 'email' => $input['email'], 'period' => $input['period'])); //save cronjob $output = shell_exec('crontab -l'); $db_backup_cron_file = "/tmp/db_backup_cron.txt"; if ($input['enable']) { if ($input['period'] == 'daily') { $daily_backup_command = '0 0 * * * wget ' . \Uri::create('backup/execute'); file_put_contents($db_backup_cron_file, $daily_backup_command . PHP_EOL); } else { if ($input['period'] == 'weekly') { $weekly_backup_command = '0 0 * * 0 wget ' . \Uri::create('backup/execute'); file_put_contents($db_backup_cron_file, $weekly_backup_command . PHP_EOL); } } } else { file_put_contents($db_backup_cron_file, "" . PHP_EOL); } exec("crontab {$db_backup_cron_file}"); \Messages::success('Settings successfully created.'); \Response::redirect('admin/backup'); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to create settings.</strong>'); // Uncomment lines below to show database errors $errors = $e->getMessage(); \Messages::error($errors); } } } } \View::set_global('title', 'Backup'); \Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false); }
protected function _execute(array $params) { if (file_exists($params['file'])) { $file = $params['file']; } else { if (file_exists(BACKUP_PLUGIN_FOLDER . $params['file'])) { $file = BACKUP_PLUGIN_FOLDER . $params['file']; } else { if (file_exists(DOCROOT . $params['file'])) { $file = DOCROOT . $params['file']; } else { Minion_CLI::write(__('File :file not found', array(':file' => $params['file']))); exit; } } } try { $backup = Model_Backup::factory($file)->restore(); Minion_CLI::write(__('Backup from file :file restored successfully', array(':file' => $file))); } catch (Exception $e) { Minion_CLI::write($e->getMessage()); } }
public function action_ajax_backup_database() { set_time_limit(0); $back = new Model_Backup(); $back->backupAll(); echo json_encode(array('status' => true)); }
public function action_ajax_upgrade_step2() { $back = new Model_Backup(); $back->backupAll(); echo json_encode(array('status' => true)); }