Reputation: 91
I'm trying to setup a automatic database backup using cron jobs in cpanel that will be emailed to myself, but running into some problems. Currently I have tried 2 different solutions, but getting similar errors.
First I tried this http://www.theblog.ca/mysql-email-backup which is to create a PHP script to be run by a cron job. But I get the error mysqldump: Can't read dir of '/etc/my.cnf.d' (Errcode: 2)
Then I tried this one http://www.canbike.org/information-technology/hostgator-wolfcms-automatic-mysql-backup.html which is simply running this cron job
mysqldump -e --user='<USERNAME>' --password='<PASSWORD>' <DATABASENAME> | gzip | uuencode <FILENAME>.gz | mail <EMAIL>
However then I get /usr/local/cpanel/bin/jailshell: uuencode: command not found
mysqldump: Can't read dir of '/etc/my.cnf.d' (Errcode: 2)
I am on a shared host and did not setup MySQL myself.
So any ideas how I can get one of these to work or even a better solution?
Upvotes: 1
Views: 2003
Reputation: 4258
uuencode
simply converts binary data (which you got as a result of gzip
compression) into text data suitable as 7-bit safe "text" data. You can try base64
instead.
You can try to use better compression as well. So instead of gzip
, try bzip2
or even better xz
, whatever is available.
For mysqldump
, have a look at the documentation:
You can use the option --no-defaults
to not try to read any options file. You can also create your own options file (maybe based on some configuration you use somewhere else already) and pass it using --defaults-file
.
Upvotes: 2