Newer
Older
FROM alpine:3.14.0
RUN apk add apk-cron mysql-client findutils
# Copy cron job file to the cron.d directory
COPY backup-cron-job /etc/cron.d/backup-cron-job
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/backup-cron-job
# Copy backup script
COPY backup.sh /etc/cron.d/backup.sh
# Give execution rights on backup script
RUN chmod 0644 /etc/cron.d/backup.sh
# Copy restore script
COPY restore.sh /etc/cron.d/restore.sh
# Give execution rights on restore script
RUN chmod 0644 /etc/cron.d/restore.sh
# Apply cron job
RUN crontab /etc/cron.d/backup-cron-job
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
CMD crond && tail -f /var/log/cron.log