469,622 Members | 1,831 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,622 developers. It's quick & easy.

How do I gzip a mysqldump sql backup file?

This is how I do a backup of a mysql database with php:

$backupFile = '/home/owner/dbbackup/'.$dbname .'-' .$filename.
'.sql';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p$dbpass $dbname>
$backupFile";
$dummy = system($command, $retval);

It works OK and creates a .sql file, but how do I compress the file to
a gzip file?

Kind regards,

Jan Nordgreen
Jun 2 '08 #1
3 5323
..oO(damezumari)
>This is how I do a backup of a mysql database with php:

$backupFile = '/home/owner/dbbackup/'.$dbname .'-' .$filename.
'.sql';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p$dbpass $dbname>
$backupFile";
$dummy = system($command, $retval);

It works OK and creates a .sql file, but how do I compress the file to
a gzip file?
Use the command line. Pass the result of mysqldump to gzip and then
redirect it to a file:

$command = "mysqldump --opt -h$dbhost
-u$dbuser -p$dbpass $dbname | gzip $backupFile.gz";

Micha
Jun 2 '08 #2
On Thu, 24 Apr 2008 19:09:13 -0700 (PDT), damezumari wrote:
This is how I do a backup of a mysql database with php:

$backupFile = '/home/owner/dbbackup/'.$dbname .'-' .$filename.
'.sql';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p$dbpass $dbname>
$backupFile";
$dummy = system($command, $retval);

It works OK and creates a .sql file, but how do I compress the file to
a gzip file?
$command = "gzip $backupFile";
$dummy = system($command, $retval);

maybe? I can't imagine that you haven't thought of this, so there must
be *something* wrong with it.

--
31. All naive, busty tavern wenches in my realm will be replaced with surly,
world-weary waitresses who will provide no unexpected reinforcement and/or
romantic subplot for the hero or his sidekick.
--Peter Anspach's list of things to do as an Evil Overlord
Jun 2 '08 #3
Thank you for your answers!

Kind regards,

Jan Nordgreen
Jun 2 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Thiko | last post: by
7 posts views Thread by Adam Smith | last post: by
reply views Thread by mcstayinskool | last post: by
3 posts views Thread by Christopher Mouton | last post: by
5 posts views Thread by Richard | last post: by
6 posts views Thread by Antoni | last post: by
7 posts views Thread by grace | last post: by
7 posts views Thread by damezumari | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.