Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. /**
  2. * [action] bakcup
  3. */
  4. public function backup(){
  5. if($this->request->is('post')){
  6. $this->autoRender = false;
  7. $db = $this->SystemTbl->getDbo();
  8. $dbHost = $db->config['host'];
  9. $dbUser = $db->config['login'];
  10. $dbPass = $db->config['password'];
  11. $dbName = $db->config['database'];;
  12. $filePath = "/var/www/tmp/";
  13. $fileName = date('ymd').'_'.date('His').'.sql';
  14. $command = "mysqldump ".$dbName." --host=".$dbHost." --user=".$dbUser." --password=".$dbPass." > ".$filePath.$fileName;
  15. system($command);
  16. $dlFile = $filePath.$fileName;
  17. header('Content-Type: application/octet-stream');
  18. header('Content-Disposition: attachment; filename="'.$fileName.'"');
  19. header('Content-Length: '.filesize($dlFile));
  20. readfile($dlFile);
  21. }else{
  22. throw new MethodNotAllowedException();
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement