Can't get crontab working for mysql backups

GreenZone

Member
I've got mysql and Xenforo running inside of Docker containers, with mapped volumes to the main virtual private server (VPS).

I'm having issues in trying to use crontab in order to schedule daily database dumps from mysql.

If I'm on the main VPS, I can successfully manually run this command in order to run a shell script inside of the mySQL Docker container in order to do the backup:
Code:
/usr/bin/docker exec -ti mysql sh -c "/var/lib/mysql/backups/xenforo_mysql_backup.sh"

If I place that same command into my crontab on the VPS, I can confirm via the system log (/var/log/syslog) that crontab is trying to initiate the command, but the command ends up not running.

The shell script being called inside of the Docker container has this within it:
Code:
/usr/bin/mysqldump --opt -uMyUser -pMyPassword xenforo > /var/lib/mysql/backups/xenforo_backup_$(/bin/date +%Y-%m-%d).sql

I'll include two screenshots with step by step demos of what's going on.

Any ideas?
 

Attachments

  • Backup2.webp
    Backup2.webp
    122.1 KB · Views: 7
  • Backup1.webp
    Backup1.webp
    122.4 KB · Views: 7
@truonglv , I gave that a try.

The crontab did kick off the command, but as before it didn't result in actually kicking off the sql dump.
See the "backup3.png" attachment.

If I run the command manually, it does work fine, also as in my prior examples.
See the "backup4.png" attachment.
 

Attachments

  • Backup4.webp
    Backup4.webp
    108.6 KB · Views: 6
  • Backup3.webp
    Backup3.webp
    87.1 KB · Views: 6
Top Bottom