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); }