Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into add-incomplete-back…
Browse files Browse the repository at this point in the history
…up-hook
  • Loading branch information
djmaze committed Apr 18, 2022
2 parents 11f2b1b + 61d12e9 commit 65412d2
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 241 deletions.
240 changes: 24 additions & 216 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,245 +1,53 @@
---
kind: pipeline
name: amd64

platform:
os: linux
arch: amd64
name: release

steps:
- name: build release
image: plugins/docker
environment:
ARCH: amd64
- name: build & push release
image: thegeeklab/drone-docker-buildx:20.11@sha256:327b6fb15dc841cf80c7c429f60d695efd7c7a476fe363afac25a58befd4c203
settings:
auto_tag: true
auto_tag_suffix: amd64
build_args_from_env:
- ARCH
repo: mazzolino/restic
platforms:
- linux/amd64
- linux/arm64
- linux/armhf
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
exclude:
- pull_request
ref:
include:
- refs/heads/master
- refs/tags/*

- name: build branch
image: plugins/docker
environment:
ARCH: amd64
settings:
build_args_from_env:
- ARCH
repo: mazzolino/restic-test
tags: ${DRONE_BRANCH}-amd64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
exclude:
- pull_request
ref:
exclude:
- refs/heads/master
- refs/tags/*

- name: build pr
image: plugins/docker
environment:
ARCH: amd64
settings:
build_args_from_env:
- ARCH
repo: mazzolino/restic-test
tags: pr-${DRONE_PULL_REQUEST}-amd64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- pull_request

---
kind: pipeline
name: arm

platform:
os: linux
arch: arm64

steps:
- name: build release
image: mazzolino/drone-docker:linux-arm
environment:
ARCH: arm
settings:
build_args_from_env:
- ARCH
auto_tag: true
auto_tag_suffix: arm
repo: mazzolino/restic
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
exclude:
- pull_request
ref:
include:
- refs/heads/master
- refs/tags/*

- name: build branch
image: mazzolino/drone-docker:linux-arm
environment:
ARCH: arm
settings:
build_args_from_env:
- ARCH
repo: mazzolino/restic-test
tags: ${DRONE_BRANCH}-arm
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
exclude:
- pull_request
ref:
exclude:
- refs/heads/master
- refs/tags/*

- name: build pr
image: mazzolino/drone-docker:linux-arm
environment:
ARCH: arm
settings:
build_args_from_env:
- ARCH
repo: mazzolino/restic-test
tags: pr-${DRONE_PULL_REQUEST}-arm
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- pull_request
trigger:
event:
exclude:
- pull_request

---
kind: pipeline
name: arm64

platform:
os: linux
arch: arm64
name: pr

steps:
- name: build release
image: plugins/docker:linux-arm64
environment:
ARCH: arm64
- name: build & push PR
image: thegeeklab/drone-docker-buildx:20.11@sha256:327b6fb15dc841cf80c7c429f60d695efd7c7a476fe363afac25a58befd4c203
settings:
auto_tag: true
auto_tag_suffix: arm64
build_args_from_env:
- ARCH
repo: mazzolino/restic
tags:
- pr-${DRONE_PULL_REQUEST}
platforms:
- linux/amd64
- linux/arm64
- linux/armhf
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
exclude:
- pull_request
ref:
include:
- refs/heads/master
- refs/tags/*

- name: build branch
image: plugins/docker:linux-arm64
environment:
ARCH: arm64
settings:
build_args_from_env:
- ARCH
repo: mazzolino/restic-test
tags: ${DRONE_BRANCH}-arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
exclude:
- pull_request
ref:
exclude:
- refs/heads/master
- refs/tags/*

- name: build pr
image: plugins/docker:linux-arm64
environment:
ARCH: arm64
settings:
build_args_from_env:
- ARCH
repo: mazzolino/restic-test
tags: pr-${DRONE_PULL_REQUEST}-arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- pull_request

---
kind: pipeline
name: manifest

steps:
- name: manifest
image: plugins/manifest:1
settings:
spec: manifest.tmpl
auto_tag: true
username:
from_secret: docker_username
password:
from_secret: docker_password
platforms:
- linux/amd64
- linux/arm
- linux/arm64
when:
event:
exclude:
- pull_request
trigger:
event:
- pull_request

depends_on:
- amd64
- arm
- arm64
---
kind: signature
hmac: 2f2c4d4cdf3e22ad6b6709a0a6bf4035f2939704b68a001d1fec069a24539dff
hmac: 979eb024a97a0673a421c496f9442193b3cbb401abdcd649a1d93e495b86601f

...
30 changes: 20 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#
FROM golang:1.15-alpine3.14 AS builder

ARG ARCH

ARG RESTIC_VERSION=0.12.1
ARG RESTIC_SHA256_AMD64=11d6ee35ec73058dae73d31d9cd17fe79661090abeb034ec6e13e3c69a4e7088
ARG RESTIC_SHA256_ARM=f27c3b271ad36896e22e411dea4c1c14d5ec75a232538c62099771ab7472765a
Expand All @@ -21,7 +19,19 @@ ARG GO_CRON_SHA256=6c8ac52637150e9c7ee88f43e29e158e96470a3aaa3fcf47fd33771a8a76d

RUN apk add --no-cache curl

RUN case "$ARCH" in \
RUN case "$(uname -m)" in \
x86_64 ) \
echo amd64 >/tmp/ARCH \
;; \
armv7l) \
echo arm >/tmp/ARCH \
;; \
aarch64) \
echo arm64 >/tmp/ARCH \
;; \
esac

RUN case "$(cat /tmp/ARCH)" in \
amd64 ) \
echo "${RESTIC_SHA256_AMD64}" > RESTIC_SHA256 ; \
echo "${RCLONE_SHA256_AMD64}" > RCLONE_SHA256 ; \
Expand All @@ -35,23 +45,23 @@ RUN case "$ARCH" in \
echo "${RCLONE_SHA256_ARM64}" > RCLONE_SHA256 ; \
;; \
*) \
echo "unknown architecture '${ARCH}'" ; \
echo "unknown architecture '$(cat /tmp/ARCH)'" ; \
exit 1 ; \
;; \
esac

RUN curl -sL --fail -o restic.bz2 https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_${ARCH}.bz2 \
RUN curl -sL --fail -o restic.bz2 https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_$(cat /tmp/ARCH).bz2 \
&& echo "$(cat RESTIC_SHA256) restic.bz2" | sha256sum -c - \
&& bzip2 -d -v restic.bz2 \
&& mv restic /usr/local/bin/restic \
&& chmod +x /usr/local/bin/restic

RUN curl -sL --fail -o rclone.zip https://github.com/rclone/rclone/releases/download/v${RCLONE_VERSION}/rclone-v${RCLONE_VERSION}-linux-${ARCH}.zip \
RUN curl -sL --fail -o rclone.zip https://github.com/rclone/rclone/releases/download/v${RCLONE_VERSION}/rclone-v${RCLONE_VERSION}-linux-$(cat /tmp/ARCH).zip \
&& echo "$(cat RCLONE_SHA256) rclone.zip" | sha256sum -c - \
&& unzip rclone.zip \
&& mv rclone-v${RCLONE_VERSION}-linux-${ARCH}/rclone /usr/local/bin/rclone \
&& mv rclone-v${RCLONE_VERSION}-linux-$(cat /tmp/ARCH)/rclone /usr/local/bin/rclone \
&& chmod +x /usr/local/bin/rclone \
&& rm -rf rclone-v${RCLONE_VERSION}-linux-${ARCH} \
&& rm -rf rclone-v${RCLONE_VERSION}-linux-$(cat /tmp/ARCH) \
&& rm rclone.zip

RUN curl -sL -o go-cron.tar.gz https://github.com/djmaze/go-cron/archive/v${GO_CRON_VERSION}.tar.gz \
Expand All @@ -69,12 +79,12 @@ RUN curl -sL -o go-cron.tar.gz https://github.com/djmaze/go-cron/archive/v${GO_C
#
FROM alpine:3.14

RUN apk add --update --no-cache ca-certificates fuse nfs-utils openssh tzdata bash curl docker-cli gzip
RUN apk add --update --no-cache ca-certificates fuse nfs-utils openssh tzdata bash curl docker-cli gzip tini

ENV RESTIC_REPOSITORY /mnt/restic

COPY --from=builder /usr/local/bin/* /usr/local/bin/
COPY backup prune check /usr/local/bin/
COPY entrypoint /

ENTRYPOINT ["/entrypoint"]
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ _Note: `BACKUP_CRON`, `PRUNE_CRON` and `CHECK_CRON` are mutually exclusive._
- `RESTIC_REPOSITORY` - Location of the restic repository. You can use [any target supported by restic](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html). Default `/mnt/restic`
- `RESTIC_BACKUP_SOURCES` - Source directory to backup. Make sure to mount this into the container as a volume (see the example configs). Default `/data`
- `RESTIC_PASSWORD` - Password for the restic repository. Will also be used to initialize the repository if it is not yet initialized
- `RESTIC_BACKUP_ARGS` - If specified `restic backup` is run with the given arguments, e.g. for tags, exclude definitions, or verbose logging: `--tag docker-volumes --exclude-file='exclude.txt' --verbose`. See the [restic backup documentation](https://restic.readthedocs.io/en/stable/040_backup.html) for available options
- `RESTIC_BACKUP_ARGS` - If specified `restic backup` is run with the given arguments, e.g. for tags, exclude definitions, or verbose logging: `--tag docker-volumes --exclude-file 'exclude.txt' --verbose`. Make sure **not** to use the `=` form of assignment, but use spaces between parameter and value. See the [restic backup documentation](https://restic.readthedocs.io/en/stable/040_backup.html) for available options
- `RESTIC_BACKUP_TAGS` - _Deprecated_. Tags to set for each snapshot, separated by commas. This option will soon be removed. Please use `RESTIC_BACKUP_ARGS` to define tags.
- `RESTIC_FORGET_ARGS` - If specified `restic forget` is run with the given arguments after each backup or before every prune, e.g. `--prune --keep-last 14 --keep-daily 1`. See the [restic forget documentation](https://restic.readthedocs.io/en/stable/060_forget.html) for available options
- `RESTIC_PRUNE_ARGS` - If specified `restic prune` is run with the given arguments, e.g. for B2 concurrent connection settings and verbose logging: `-o b2.connections=10 --verbose`.
Expand Down
Loading

0 comments on commit 65412d2

Please sign in to comment.