1

I have the following script in /etc/cron.daily/, it works perfectly if I execute it manually but never runs via cron. There are other scripts in cron.daily that do execute however.

#!/bin/bash
DATE=`date +%Y%m%d`
FILENAME=mysql_$DATE.tar.gz
DESDIR=/data/mysqlbackup/

echo Deleting backups older than 30 days
echo Files deleted:
find /data/mysqlbackup/ -mtime +30 -type f -ls
find /data/mysqlbackup/ -mtime +30 -type f -delete

echo Backing up all databases
mysqldump -u backup -p --all-databases --events | gzip > $DESDIR$FILENAME

echo Backup complete:
ls -lh $DESDIR

What could the issue be?

I'm running Ubuntu 14.04

2 Answers2

1

set Path for mysqldump in bash or shell script like whereis mysqldump and add full path in scrip

/usr/bin/mysqldump -u root -p database > /backuppath/mysqldumpdate.sql
Rinzwind
  • 309,379
1

set Path for mysqldump in your shell script and then add full path in script as below.

For example : in your script

   mysqlpath=/path/to/mysql/instalation/bin

   $mysqlpath/mysqldump -u $USER -p$PASSWORD -h$IP  $DATABASE  > $BACKUP_DIR/$DATABASE.$DATE_STAMP.sql
dash
  • 11