This commit is contained in:
f 2019-09-10 21:15:08 -03:00
parent a2e27c5316
commit d173dd6e4a
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
3 changed files with 32 additions and 0 deletions

View file

@ -1,2 +1,14 @@
FROM sutty/monit:latest FROM sutty/monit:latest
MAINTAINER "f <f@sutty.nl>" MAINTAINER "f <f@sutty.nl>"
ENV BORG_HOST_ID borg
ENV BORG_PASSPHRASE ""
ENV KEEP 30
COPY ./monit.conf /etc/monit.d/borg.conf
COPY ./backup.sh /usr/local/bin/backup
RUN apk add --no-cache borgbackup
VOLUME /srv/data
VOLUME /srv/backups

16
backup.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
set -e
# Password can't be empty
test -n "${BORG_PASSPHRASE}"
date="$(date +%F)"
orig=/srv/data
dest=/srv/backups
test -f "${dest}/config" || borg init --encryption=repokey "${dest}"
borg create -v --stats "${dest}::${date}" "${orig}"
borg prune -v --stats --keep-daily ${KEEP} "${dest}"
exit $?

4
monit.conf Normal file
View file

@ -0,0 +1,4 @@
check program backup
with path "/usr/local/bin/backup"
if status != 0 then alert
every "53 3 * * *"