Answer the question
In order to leave comments, you need to log in
Docker. docker-compose. Run via cron. How?
There is a server with a docker environment... everything works, everything is fine...
There is a container with MariaDB...
In cron I do two commands for testing:
*/5 * * * * cd /home/USER/ && /usr/local/bin/docker-compose -f prod-compose.yml exec mariadb /usr/bin/mysqldump -u USER -pPASSWORD --single-transaction DB_NAME | gzip > /home/USER/BACKUP/DB_$(date +%d-%m-%Y_%H_%M_%S).sql.tar.gz
*/5 * * * * touch /home/USER/BACKUP/test.txt
Answer the question
In order to leave comments, you need to log in
In general, I won ... It was in the -T
flag to the docker-compose exec command.
Why read the documentation for this flag .
As a result, the command is:
*/5 * * * * cd /home/USER/ && /usr/local/bin/docker-compose -f prod-compose.yml exec -T mariadb /usr/bin/mysqldump -u USER -pPASSWORD --single-transaction DB_NAME | gzip > /home/USER/BACKUP/DB.sql.tar.gz
1) look for errors when running from cron - in the mail if there is no redirect
2) try without a timestamp in the file name - I remember that there were some problems
Maybe so
*/5 * * * * /usr/local/bin/docker-compose -f /home/USER/prod-compose.yml exec mariadb /usr/bin/mysqldump -u USER -pPASSWORD --single-transaction DB_NAME | gzip > /home/USER/BACKUP/DB_$(date +%d-%m-%Y_%H_%M_%S).sql.tar.gz
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question