Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. use Drupal\Core\Database\Database;
  2. $connection_info = Database::getConnectionInfo('default');
  3.  
  4. $db = $connection_info['default']['database'];
  5. $u = $connection_info['default']['username'];
  6. $p = $connection_info['default']['password'];
  7. $current_date = date('Y-m-d_H-i-s');
  8.  
  9. $command = "mysqldump --user=$u --password=$p $db";
  10. $dump = shell_exec($command);
  11.  
  12. header('Content-Description: File Transfer');
  13. header('Content-Type: application/octet-stream');
  14. header('Content-Disposition: attachment; filename='.basename($db . '_' . $current_date . '.sql'));
  15.  
  16. echo $dump;
  17. exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement