Can't get crontab working for mysql backups


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:
/usr/bin/docker exec -ti mysql sh -c "/var/lib/mysql/backups/"

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:
/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?


  • Backup2.png
    93.8 KB · Views: 7
  • Backup1.png
    98.8 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.


  • Backup4.png
    77.2 KB · Views: 6
  • Backup3.png
    64.4 KB · Views: 6
Top Bottom