This is a very basic mysqldump script that will do a dump and store it locally.
Running mysqldump by itself works fine as does gzip (i.e. they are where they need to be in my path)
/usr/bin/mysqldump --database $DBNAME --opt --single-transaction -u $USER -p $PASS
But when I try to pipe the output to gzip and then write that to a file I run into an error:
/var/www/vhosts/meh/mysqlbackup/mysqlbackup.sh: line 18: /var/www/vhosts/meh/mysqlbackup/mehbackup.sql.gz: No such file or directory
mysqldump: Got errno 32 on write
Here is the line 18 referenced in the error:
/usr/bin/mysqldump --database $DBNAME --opt --single-transaction -u$USER -p$PASS | /usr/bin/gzip -9 > $OUTDIR$OUTFILE
That error number 32 seems to be a broken pipe error so... I'm assuming that , since mysqldump can run fine, I am having an issue writing the results? A permissions issue maybe?
The permissions on the dir I am writing to are 766 (rwxrw-rw-)
I am running this under super user permissions (su
)
I want to set this up to run via cron but until I figure out why this is failing... no love.
-
Check path:
file /var/www/vhosts/meh/mysqlbackup/ ls -ald /var/www/vhosts/meh/mysqlbackup/
and create dir:
mkdir -p /var/www/vhosts/meh/mysqlbackup/
From bindbn -
See if you can do this:
$ echo "woo" | gzip > asdf.gz $ gunzip asdf.gz cat asdf
That should tell you that your gzip stuff is working fine. If you're not doing your gzip stuff the way I just did it, maybe try it the way I just did it.
In other words, try this:
/usr/bin/mysqldump --database $DBNAME --opt --single-transaction -u $USER -p $PASS | gzip /var/www/vhosts/meh/mysqlbackup/dump.gz
From Jason Swett -
Another distinct possibility: you have "/var/www/vhosts/meh/mysqlbackup" in one instance and "/var/www/vhosts/meh/mysqlbackups" in another instance. Maybe that's it.
Lothar_Grimpsenbacher : Ugh, sorry. That was a typo on my part while putting this in. It is correct in the actual script. Good point though, as such things can so easily be the problem.From Jason Swett
0 comments:
Post a Comment