4

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");  
2
  • Why are you using passthru() with redirection? Commented Apr 13, 2012 at 4:56
  • I assumed this was the correct method to employ. I have come across many examples of this, just not a full explanation about how to incorporate gzip compression. Commented Apr 13, 2012 at 5:21

1 Answer 1

7

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

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.