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
1 changed files with 10 additions and 1 deletions

View File

@ -14,6 +14,7 @@ class DumpMySQL extends BuildTask
public function run($request)
{
$fileName = 'backup-'.date('d-m-Y').'.sql';
$cfg = DB::getConfig();
try {
@ -21,7 +22,15 @@ class DumpMySQL extends BuildTask
} 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']);
exit(0);
}