SOLVED Problem with command line mysqldump database backups

celiac101

Well-Known Member
Dec 19, 2012
112
3
68
cPanel Access Level
Website Owner
I am having some trouble getting a command line mysqldump to work. Once a day I want to do a mysqldump of my database to a backup. Below is the command line, and I can't get it to work with or without passwords. Does anyone know why?

SHELL="/bin/bash"
35 1 * * 0 mysqldump -q my_forum_mysql_database -usite_user -pPASSwordhere > /backup/my_forum_backup_sunday.sql >/dev/null 2>&1

It is creating a file named my_forum_backup_sunday.sql with zero size.
 

HostNoc

Well-Known Member
Feb 20, 2020
117
28
28
Ontario
cPanel Access Level
Root Administrator
Hi

Please try this

/usr/local/mysql/bin/mysqldump -uroot -ppassword --opt database > /path/to/directory/filename.sq

Note: There is no space between the -p and password or -u and username - replace root with a correct database username.

Regards
HostNoc
 

celiac101

Well-Known Member
Dec 19, 2012
112
3
68
cPanel Access Level
Website Owner
mysqldump works fine with command line, and when I run it from command I don't need to include a password or user, I simply use this when logged in as root, and it works fine:
mysqldump -q my_database_name > /backup/my_file_name.sql

This, however, will not work as a cronjob.

The closest I may have come to this working as a cronjob is below:
mysqldump -q my_database_name -umyusername -pmyuserpassword > /backup/my_file_name.sql

and I get this error when I run that from a cronjob:
/usr/local/cpanel/bin/jailshell: /backup/my_file_name.sql: No such file or directory