archive
commit
9684eedac7
|
|
@ -0,0 +1,4 @@
|
||||||
|
*.sw*
|
||||||
|
backup/
|
||||||
|
mnt/
|
||||||
|
restore/
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29
|
||||||
|
|
||||||
|
RUN apk update && apk add --no-cache \
|
||||||
|
python3 \
|
||||||
|
curl \
|
||||||
|
bash
|
||||||
|
|
||||||
|
WORKDIR /opt
|
||||||
|
RUN curl -L \
|
||||||
|
https://github.com/borgbackup/borg/releases/download/1.1.9/borg-linux64 \
|
||||||
|
> ./borg \
|
||||||
|
&& chmod +x ./borg
|
||||||
|
RUN pip3 install --upgrade borgmatic \
|
||||||
|
&& generate-borgmatic-config \
|
||||||
|
&& cp /etc/borgmatic/config.yaml /etc/borgmatic/sample.config.yaml
|
||||||
|
RUN mkdir -p /backup /mnt
|
||||||
|
|
||||||
|
VOLUME /etc/borgmatic/
|
||||||
|
VOLUME /mnt
|
||||||
|
VOLUME /backup
|
||||||
|
|
||||||
|
ENV BORG_PASSPHRASE=a
|
||||||
|
|
||||||
|
COPY ./entrypoint.sh ./entrypoint.sh
|
||||||
|
COPY ./config.yaml /etc/borgmatic/config.yaml
|
||||||
|
|
||||||
|
CMD []
|
||||||
|
ENTRYPOINT ["bash", "entrypoint.sh"]
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")" >&2
|
||||||
|
|
||||||
|
mkdir -p ./{restore,mnt,backup} >&2
|
||||||
|
|
||||||
|
img="${IMG:-dev:dev}"
|
||||||
|
|
||||||
|
docker build -t $img . >&2
|
||||||
|
|
||||||
|
if [ -z "${BUILD:-""}" ]; then
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
-it \
|
||||||
|
-e BORG_PASSPHRASE="${BORG_PASSPHRASE:-"a"}" \
|
||||||
|
-v $PWD/restore:/opt/mnt \
|
||||||
|
-v $PWD/mnt:/mnt \
|
||||||
|
-v $PWD/backup:/backup \
|
||||||
|
-v $PWD/config.yaml:/etc/borgmatic/config.yaml:ro \
|
||||||
|
$img \
|
||||||
|
"$@"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
location:
|
||||||
|
source_directories:
|
||||||
|
- /mnt
|
||||||
|
repositories:
|
||||||
|
#- user@backupserver:sourcehostname.borg # ssh example
|
||||||
|
- /backup
|
||||||
|
exclude_if_present: .nobackup # do not back up dirs containing X
|
||||||
|
local_path: /opt/borg
|
||||||
|
|
||||||
|
#exclude_patterns:
|
||||||
|
# - '*.pyc'
|
||||||
|
# - ~/*/.cache
|
||||||
|
# - /etc/ssl
|
||||||
|
#exclude_from:
|
||||||
|
# - /etc/borgmatic/excludes
|
||||||
|
|
||||||
|
|
||||||
|
storage:
|
||||||
|
checkpoint_interval: 600 # checkpoint every X seconds during backup
|
||||||
|
compression: lz4
|
||||||
|
|
||||||
|
#remote_rate_limit: 100 # KB per Sec
|
||||||
|
#ssh_command: ssh -i /path/to/private/key
|
||||||
|
#archive_name_format: '{hostname}-documents-{now}' # borg help placeholders
|
||||||
|
|
||||||
|
retention:
|
||||||
|
keep_daily: 7
|
||||||
|
|
||||||
|
#keep_within: 3H # Keep all archives within this time interval.
|
||||||
|
#keep_secondly: 60
|
||||||
|
#keep_minutely: 60
|
||||||
|
#keep_hourly: 24
|
||||||
|
#keep_weekly: 4
|
||||||
|
#keep_monthly: 6
|
||||||
|
#keep_yearly: 1
|
||||||
|
|
||||||
|
#hooks:
|
||||||
|
#before_backup:
|
||||||
|
# - echo "Starting a backup job."
|
||||||
|
#after_backup:
|
||||||
|
# - echo "Backup created."
|
||||||
|
#on_error:
|
||||||
|
# - echo "Error while creating a backup."
|
||||||
|
|
||||||
|
consistency:
|
||||||
|
checks:
|
||||||
|
- repository
|
||||||
|
#- disabled
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
Borgmatic --init --encryption repokey --verbosity 1 >&2 || true
|
||||||
|
if [ "$#" -gt 0 ]; then
|
||||||
|
Borgmatic "$@"
|
||||||
|
else
|
||||||
|
Borgmatic --prune --verbosity 1
|
||||||
|
Borgmatic --create --progress --verbosity 1
|
||||||
|
Borgmatic --check --verbosity 1 # expensive
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function Borgmatic() {
|
||||||
|
log borgmatic "$@"
|
||||||
|
borgmatic "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
echo "[$(date +%Y-%m-%d-%H:%M:%S)] $@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$0" == "${BASH_SOURCE[0]}" ]; then
|
||||||
|
main "$@"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
mnt
|
||||||
|
|
@ -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"]
|
||||||
|
|
@ -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 \
|
||||||
|
"$@"
|
||||||
|
|
@ -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/"
|
||||||
Loading…
Reference in New Issue