From 609e879ffd4d55a94654c405b80dddc6d3b8549f Mon Sep 17 00:00:00 2001 From: Grant Bevis Date: Wed, 16 Aug 2017 12:37:29 +0100 Subject: [PATCH] Initial Commit --- Dockerfile | 29 ++++++++++++++++++++++ README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ crontab.txt | 1 + entry.sh | 5 ++++ 4 files changed, 106 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 crontab.txt create mode 100644 entry.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..748d1f8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM alpine:latest +MAINTAINER b3vis +COPY entry.sh /entry.sh +RUN apk upgrade --no-cache \ + && apk add --no-cache \ + curl \ + sshfs \ + python3 \ + py3-msgpack \ + ca-certificates \ + openssl-dev \ + lz4-dev \ + musl-dev \ + gcc \ + python3-dev \ + acl-dev \ + && pip3 install --upgrade pip \ + && pip3 install --upgrade borgbackup \ + && pip3 install --upgrade borgmatic \ + && mkdir /config /cache /source /repository \ + && rm -rf /var/cache/apk/* \ + && chmod 755 /entry.sh +VOLUME /config +VOLUME /cache +VOLUME /source +VOLUME /repository +# Set Envars +ENV BORG_CACHE_DIR /cache +CMD ["/entry.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..b69248c --- /dev/null +++ b/README.md @@ -0,0 +1,71 @@ +# Borgmatic Container + +### Description + +A little container I wrote to automate my [Borgbackup](https://github.com/borgbackup)'s using the excellent [Borgmatic](https://github.com/witten/borgmatic). + +It uses cron to run the backups at a time you can configure in `crontab.txt`. + +### Usage + +You will need to create crontab.txt and your borgmatic config.yml and mount these files into your /config directory. When the container starts it creates the crontab from /config/crontab.txt and starts crond. + +### Example run command +``` +docker run -d \ + -v /home:/source/home:ro \ + -v /mnt/borg:/repository \ + -v /srv/borgmatic/config:/config \ + -v /srv/borgmatic/cache:/cache \ + b3vis/borgmatic +``` + +### Layout + +#### /config +Where you need to create crontab.txt and your borgmatic config.yml + +#### crontab.txt example +In this file set the time you wish for your backups to take place default is 1am every day. In here you can add any other tasks you want ran +``` +0 1 * * * root PATH=$PATH:/usr/bin /usr/bin/borgmatic -c /config -v 1 2>&1 +``` +#### /cache +A non volatile place to store the borg chunk cache +#### /source +Your data you wish to backup +#### /repository +Mount your borg backup repository here + +### Dockerfile +``` +FROM alpine:latest +MAINTAINER b3vis +COPY entry.sh /entry.sh +RUN apk upgrade --no-cache \ + && apk add --no-cache \ + curl \ + sshfs \ + python3 \ + py3-msgpack \ + ca-certificates \ + openssl-dev \ + lz4-dev \ + musl-dev \ + gcc \ + python3-dev \ + acl-dev \ + && pip3 install --upgrade pip \ + && pip3 install --upgrade borgbackup \ + && pip3 install --upgrade borgmatic \ + && mkdir /config /cache /source /repository \ + && rm -rf /var/cache/apk/* \ + && chmod 755 /entry.sh +VOLUME /config +VOLUME /cache +VOLUME /source +VOLUME /repository +# Set Envars +ENV BORG_CACHE_DIR /cache +CMD ["/entry.sh"] +``` diff --git a/crontab.txt b/crontab.txt new file mode 100644 index 0000000..2fa5ba1 --- /dev/null +++ b/crontab.txt @@ -0,0 +1 @@ +0 1 * * * root PATH=$PATH:/usr/bin /usr/bin/borgmatic -c /config -v 1 2>&1 diff --git a/entry.sh b/entry.sh new file mode 100644 index 0000000..7a8f13a --- /dev/null +++ b/entry.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# Import your cron file +/usr/bin/crontab /config/crontab.txt +# Start cron +/usr/sbin/crond -f -L /config/crond.log