A simple Docker image to periodically backup directories on my server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
742 B

FROM ubuntu:18.04
# See: https://unix.stackexchange.com/questions/433942/how-to-specify-extra-tz-info-for-apt-get-install-y-awscli
RUN export TZ=Europe/London
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Prepare apt repos
RUN apt-get update
RUN apt-get install -y cron awscli
# Create needed dirs and add files
RUN mkdir /backup
COPY backup.sh /usr/local/bin/backup
COPY entry.sh /entry.sh
# Prepare cron job
RUN echo '0 3 * * * /usr/local/bin/backup >> /var/log/backup.log 2>&1\n' > /etc/cron.d/backup-cron
RUN chmod 0644 /etc/cron.d/backup-cron
RUN crontab /etc/cron.d/backup-cron
RUN touch /var/log/backup.log
# Entry file tails cron job log to ensure container keeps running
CMD ["/entry.sh"]