Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gzip compression with mysqldump

Tags:

php

mysql

gzip

Can anyone provide an example of how I can include a path to my zip compression software within the following php code? The code works when dumping into a simple sql file, however, gzip compression obviously relies on including the correct path.

$dumpfile = $dbname . ".sql.gz"; 

passthru("c:\\xampp\\mysql\\bin\\mysqldump.exe --opt --host=$dbhost --user=$dbuser --password=$dbpwd $dbname | gzip -v -9 > $dumpfile");  
like image 326
mojobullfrog Avatar asked Oct 27 '25 02:10

mojobullfrog


1 Answers

You are missing the -c option to gzip that tells it to output to standard output. Otherwise it expects to operate on files.

use ... | gzip -9 -c > $dumpfile

like image 70
D Mac Avatar answered Oct 28 '25 18:10

D Mac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!