This commit is contained in:
bel
2021-09-14 06:38:09 -06:00
commit 9684eedac7
9 changed files with 180 additions and 0 deletions

1
restic/.dockerignore Executable file
View File

@@ -0,0 +1 @@
mnt

22
restic/Dockerfile Executable file
View File

@@ -0,0 +1,22 @@
FROM golang:1.12.5-alpine3.9 as rbuilder
ENV GOPATH=/go
RUN apk add --no-cache git bash ca-certificates
RUN go get github.com/restic/restic
WORKDIR /go/src/github.com/restic/restic/cmd/restic
RUN git checkout v0.9.5
RUN CGO_ENABLED=0 go build -o /go/bin/restic -a -installsuffix cgo
FROM alpine:3.9
WORKDIR /main
RUN apk add --no-cache ca-certificates bash
COPY --from=rbuilder /go/bin/ /main
VOLUME /mnt
RUN echo \
'out="$(/main/restic init /mnt 2>&1 | grep -v config.file.already.exists | grep -v created.restic.repository | tr -d "\\n" )"; if test -n "$out"; then printf "ERR: $out\n"; else exec /main/restic "$@"; fi' \
> /entrypoint.sh \
&& chmod +x /entrypoint.sh
CMD []
ENTRYPOINT ["bash", "/entrypoint.sh"]

16
restic/build.sh Executable file
View File

@@ -0,0 +1,16 @@
#! /bin/bash
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
IMG=bel/restic:v0.0
docker build -t $IMG .
mkdir -p ./mnt
docker run \
--rm \
-it \
-v $PWD/mnt:/mnt \
$MNT \
$IMG \
"$@"

8
restic/sample.sh Executable file
View File

@@ -0,0 +1,8 @@
#! /bin/bash
MNT="-e RCLONE_BWLIMIT=4.5mb -e RESTIC_REPOSITORY=/mnt -e RESTIC_PASSWORD=test -v $HOME:/src" \
bash build.sh \
backup \
/src/Go/src/local/dockers/cal \
-v \
--exclude "**/mnt/"