Answer the question
In order to leave comments, you need to log in
How to do cron dumps in Docker?
Hello!
I have: docker-compose, it has 2 containers, one with PHP, the other with PostgreSQL.
It is necessary: to send a postgres dump via ftp using Cron.
I managed to write a bash script for the host machine, and send dumps from it, but using the host machine is not convenient, I want the container to start and deal with dumps.
I can't figure out how to call pg_dump_all from one container in a potsgres container.
Putting ssh everywhere is reluctant/wrong.
I will be glad to any thoughts!
Thank you!
Answer the question
In order to leave comments, you need to log in
As an option
, add supervisor + cron in the postgres container, tell the supervisor to monitor cron, run cron through the supervisor with the -f flag, add the backup command to crontab immediately when the container starts via RUN echo or whatever is convenient.
The supervisor will monitor the state of cron and prevent it from falling, and then everything is as planned - according to the schedule, the backup task will be started and uploaded where necessary. I have this option on one container where I need to update the data.
The second option is to send a command to the container via cron on the host
docker exec -it container_name /path/to/backup_scipt.sh
Here you need to store a script in the container that will do everything you need.
Both options need to be tested.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question