Shell Sh script for db backup using mysqldump

Hi ,

I've created a shell script to take backup of my db and scheduled it through cron.
However the scheduled cron job is not taking any backup.

When I execute the script manually using the sudo user it is giving the required result.

upload_2015-10-15_18-1-3.png


Also I've mentioned the complete path for mysqldump in the script.

Code:
#!/bin/sh
/usr/local/bin/mysqldump --defaults-extra-file=$MY_CNF --defaults-group-suffix=*** user=*** db> ${BACKUP_DIR}/backup-file_${DATE}.sql

Could someone please help on this.
 
Redirect the output of the script to a log file instead of /dev/null. That way you can probably find out why it's not working.
 
Redirect the output of the script to a log file instead of /dev/null. That way you can probably find out why it's not working.

I got the access denied error.
Code:
Got error: 1045: Access denied for user 'exports_script'@'localhost' (using password: YES) when trying to connect.
But when iI manually run the script this error doesn't occur.

How should iI resolve it?
 
Code:
user=***
Should be
Code:
--user=***

Because the argument is ignored it will try to login as the user that's running the script. Which may not be the same user as the one provided with --user.
 
Code:
user=***
Should be
Code:
--user=***

Because the argument is ignored it will try to login as the user that's running the script. Which may not be the same user as the one provided with --user.
Tried with --user. Still the same error.
 
Back
Top