July 17, 201411 yr How can one add a cron job to a docker container in particular the mariadb container. I would like to be able to backup the xbmc databases in case of something, most of it I care for the watched status. Thank you.
July 17, 201411 yr Take a look at Needo's plexWatch Docker: https://github.com/needo37/plexWatch It contains a cronjob
July 21, 201411 yr Author Thanks for the tip. I managed to add cron to needo's image like this: Dockerfile: FROM needo/mariadb:latest MAINTAINER soana <[email protected]> ENV DEBIAN_FRONTEND noninteractive # Add our crontab file ADD crontab.txt /config/crontab.txt ADD cronjob /config/cronjob #Use the crontab file RUN crontab /config/crontab.txt # Start cron RUN cron VOLUME /backup cronjob file: #!/bin/bash ##backup databases mysqldump -u root MyMusic46 > /backup/MyMusic_$(date +%Y-%m-%d).sql mysqldump -u root MyVideos78 > /backup/MyVideos_$(date +%Y-%m-%d).sql ##Delete files "My*" older than 5 days find /backup/My* -mtime +4 -exec rm {} \; Reminder don't forget to chmod +x this file before building the image crontab.txt 00 3 * * * /config/cronjob Now I'm looking into a way to be able to edit the crontab.txt and cronjob files while the container is running eliminating the need to rebuild the image every time one of these files have to change. I'm sure someone will come up with a much more elegant solution eventually but until then I have my sql backups and I'm happy with my Linux noob solution.
Archived
This topic is now archived and is closed to further replies.