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.