commit
b55ab2be42
3 changed files with 45 additions and 0 deletions
@ -0,0 +1,24 @@
|
||||
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"] |
||||
|
@ -0,0 +1,14 @@
|
||||
#!/bin/bash |
||||
set -e |
||||
|
||||
filename="backup.tar.gz" |
||||
|
||||
cd /backup |
||||
|
||||
echo "Creating archive..." |
||||
echo $BACKUP_DIRS | tr " " "\n" > files.txt |
||||
rm $filename 2>&1 || true |
||||
tar --warning=no-file-changed -czf $filename -T files.txt 2>&1 || true |
||||
|
||||
echo "Uploading to Backblaze..." |
||||
aws s3 cp $filename "s3://$BUCKET/$filename" --endpoint-url "$ENDPOINT" |
Loading…
Reference in new issue