FIX: mysql dump gzip is on

This commit is contained in:
Tony Air 2022-02-09 23:09:19 +02:00
parent 3d58ada608
commit c9107fe581

View File

@ -14,6 +14,7 @@ class DumpMySQL extends BuildTask
public function run($request) public function run($request)
{ {
$fileName = 'backup-'.date('d-m-Y').'.sql';
$cfg = DB::getConfig(); $cfg = DB::getConfig();
try { try {
@ -21,7 +22,15 @@ class DumpMySQL extends BuildTask
} catch (Exception $e) { } catch (Exception $e) {
} }
header('Content-Disposition: attachment; filename="backup-'.date('d-m-Y').'.sql"'); // check if gzip is on
try {
if (count(array_intersect(['mod_deflate', 'mod_gzip'], apache_get_modules())) > 0) {
$fileName .= '.gz';
}
} catch (Exception $e) {
}
header('Content-Disposition: attachment; filename="'.$fileName.'"');
passthru('mysqldump -u '.$cfg['username'].' --password="'.$cfg['password'].'" '.$cfg['database']); passthru('mysqldump -u '.$cfg['username'].' --password="'.$cfg['password'].'" '.$cfg['database']);
exit(0); exit(0);
} }