I created a script to back up my databases and my websites. It runs fine if I run it straight up but it's not running at all as a cron job.
I created a symbolic link to the script:
lrwxrwxrwx 1 root root 44 Feb 11 14:58 backupsql -> /home/techguyalabama/dropboxbackup/backupsql
If I run the backupsites
from the /etc/cron.daily
directory, it does prompt me for my password. I'm not sure if that is the issue. If it is, how do I avoid that?
I did make a change to the time that cron jobs run. Maybe that's a no-no also?
This is in my crontab:
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
05 5 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
30 5 * * 6 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
00 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
I did restart the server to see if that made a difference and it did not.
I also checked the syslog, from this post Where is the cron / crontab log?, to see if there was anything in there about the backupsql:
tail -f /var/log/syslog | grep backupsql
I got no results.
Anyone see what I am doing wrong?
EDIT#1
This is my backupsql script:
#!/bin/bash
DB_BACKUP="/home/techguyalabama/dropboxbackup/sqlbackup"
DB_USER="root"
DB_PASSWD="wouldntyouliketoknow"
HN=`hostname | awk -F. '{print $1}'`
# Create the backup directory
mkdir -p $DB_BACKUP
# Backup each database on the system
for db in $(mysql --user=$DB_USER --password=$DB_PASSWD -e 'show databases' -s --skip-column-names|grep -viE '(staging|performance_schema|information_schema)');
do mysqldump --user=$DB_USER --password=$DB_PASSWD --events --opt --single-transaction $db | gzip > "$DB_BACKUP/mysqldump-$HN-$db-$(date +%Y-%m-%d).gz";
done
/home/techguyalabama/dropboxbackup/dropbox_uploader.sh upload /home/techguyalabama/dropboxbackup/sqlbackup/*.* /sqlbackup/
rm -f /home/techguyalabama/dropboxbackup/sqlbackup/*.*