From c9107fe581e7d9e10010183478043ca5320c0517 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Wed, 9 Feb 2022 23:09:19 +0200 Subject: [PATCH] FIX: mysql dump gzip is on --- src/Tasks/DumpMySQL.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Tasks/DumpMySQL.php b/src/Tasks/DumpMySQL.php index 18ab378..7c3a785 100755 --- a/src/Tasks/DumpMySQL.php +++ b/src/Tasks/DumpMySQL.php @@ -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); }