For some reason gzip doesn't work. It gives me an empty file
/usr/bin/mysqldump --opt -u root -ppassword database > database.sql | gzip > database.sql.gz
database.sql is correctly created and it has the correct size.
However database.sql.gz is only 20kb and it contains an empty file.
thanks
Your syntax is wrong here. Because you're sending the output from the mysqldump command to database.sql, there's no output left to be piped through to gzip. Just remove that bit, so you're only creating the gzipped file:
/usr/bin/mysqldump --opt -u root -ppassword database | gzip > database.sql.gz
If you really want to create compressed and uncompressed versions, you'll either need to run two separate commands:
/usr/bin/mysqldump --opt -u root -ppassword database > database.sql ; cat database.sql | gzip > database.sql.gz
or use tee to split the output:
/usr/bin/mysqldump --opt -u root -ppassword database | tee database.sql | gzip > database.sql.gz
Try this
pipeline means that you are NOT writing to file, so just remove " > database.sql" in your one-liner.
Try something like this instead:
/usr/bin/mysqldump --opt -u root -ppassword database | gzip > database.sql.gz
Because there is no more ouput after the creation of the sql file database.sql. It does not continue so the pipe does not receive any data. you could do this:
mysqldump -u root -p auth > data.sql && gzip data.sql
The problem is that you are trying to redirect the output both to a file and to a pipe.
If you want to compress the output of the command to a file you must use: