1

I've written a script which backups my MySQL database and produces a GZIP file with the mysql dump of my database. I wondered if it's possible to decompress the GZIP file and restore the database in one single command?

Something like this:

mysql -u user -h host -ppass database < gzip -c database.backup

But this doesn't seem to work. Any suggestions?

I use the following command:

mysqldump -u user -h host -ppass database | gzip -9 > database.backup

The error I get is: -bash: gzip: No such file or directory; which, in my opinion, indicates that it does not recognise gzip as a command or something like that

1
  • No, it indicates that the database.backup file doesn't exist. Are you sure it's there?
    – slhck
    Feb 28, 2013 at 15:20

2 Answers 2

1

You're using two commands so you should use a pipe and not redirection. I use this:

gunzip < file.gz | mysql <parameters>
0
0

Normally this should work. Is gzip installed and available in the PATH-Variable ? (You can test it with command "which gzip"

mysqldump -u user -h host -ppass database | gzip -9 > database.backup

but i would use as backup-file the suffix .gz

You also can try

mysqldump -u user -h host -ppass *--database* "db_name" | gzip -9 > "db_backup".backup.gz

I wrote a script recently to make a compressed backup of my databases.

http://infofreund.de/easy-mysql-backup/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .