Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * [action] bakcup
- */
- public function backup(){
- if($this->request->is('post')){
- $this->autoRender = false;
- $db = $this->SystemTbl->getDbo();
- $dbHost = $db->config['host'];
- $dbUser = $db->config['login'];
- $dbPass = $db->config['password'];
- $dbName = $db->config['database'];;
- $filePath = "/var/www/tmp/";
- $fileName = date('ymd').'_'.date('His').'.sql';
- $command = "mysqldump ".$dbName." --host=".$dbHost." --user=".$dbUser." --password=".$dbPass." > ".$filePath.$fileName;
- system($command);
- $dlFile = $filePath.$fileName;
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="'.$fileName.'"');
- header('Content-Length: '.filesize($dlFile));
- readfile($dlFile);
- }else{
- throw new MethodNotAllowedException();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement