Issue
I am using docker with docker compose on my server (debian 7.5).
I have 1 mysql container and one postgresql container for 2 applications.
When i want to create a backup of my database (for example for the database "mydb" from my mysql container) I do like this :
docker exec -it <my_container_id> mysqldump --opt mydb > "/backup/mydb$(date +%Y%m%dà%H%M).sql"
It works very well. The backup is saved in my local server.
The thing is I want to create this task everyday. So i created a file "backup.sh" in /etc/cron.daily/. (and then I did chmod +x backup.sh).
But the problem is, the cron doesn't work at all. I can see in the log that the file is executed, but I don't have anything in my backup folder.
Someone has an issue ?
Thank you very much
Solution
Cron does not set the PATH
unless you specify it.
Try with the docker absolute path (/usr/bin/docker
most likely) in your shell script.
Answered By - Thomasleveil Answer Checked By - David Marino (WPSolving Volunteer)