Compare commits
43 commits
aumentar-t
...
antifascis
Author | SHA1 | Date | |
---|---|---|---|
|
288a6acca2 | ||
|
0e8b6ac71a | ||
|
fc1a12e592 | ||
|
000ac53f39 | ||
|
ba79200e65 | ||
|
41354bbc95 | ||
|
c0e6b8150b | ||
|
f7da597784 | ||
|
dfb6f210d3 | ||
|
b99a8111d8 | ||
|
aa086a76af | ||
|
2a72840be0 | ||
|
397dff920a | ||
|
0e562d41fe | ||
|
e66b364db7 | ||
|
b921379aa0 | ||
|
8dd7d4605a | ||
|
d11e588f03 | ||
|
72e0c22208 | ||
|
5085c7e8df | ||
|
3163150be5 | ||
|
91bf0bbe06 | ||
|
1233c89aff | ||
|
5e098f58e9 | ||
|
3dde92d4de | ||
|
3e098e8c24 | ||
|
582b83d3fa | ||
|
5d35cad642 | ||
|
d369aed22d | ||
|
8b7dc40079 | ||
|
1ec77166f8 | ||
|
5b120ed353 | ||
|
5d34acde46 | ||
|
15d48f3d55 | ||
|
91958cf969 | ||
|
eb02287940 | ||
|
fedf64f2b9 | ||
|
24c31e7eb8 | ||
|
da19bd76f8 | ||
|
1068b67884 | ||
|
434501ef54 | ||
|
dcf07f90e7 | ||
|
4aa380ee62 |
4 changed files with 48 additions and 29 deletions
|
@ -1,23 +1,24 @@
|
|||
pipeline:
|
||||
steps:
|
||||
publish:
|
||||
image: plugins/docker
|
||||
image: "docker.io/woodpeckerci/plugin-docker-buildx"
|
||||
settings:
|
||||
registry: registry.nulo.in
|
||||
username: sutty
|
||||
repo: registry.nulo.in/sutty/borg
|
||||
registry: "https://gitea.nulo.in"
|
||||
username: "sutty"
|
||||
repo: "gitea.nulo.in/sutty/borg"
|
||||
tags:
|
||||
- ${ALPINE_VERSION}
|
||||
- latest
|
||||
- "${ALPINE_VERSION}"
|
||||
- "latest"
|
||||
build_args:
|
||||
- ALPINE_VERSION=${ALPINE_VERSION}
|
||||
- BASE_IMAGE=registry.nulo.in/sutty/monit
|
||||
secrets:
|
||||
- docker_password
|
||||
- "ALPINE_VERSION=${ALPINE_VERSION}"
|
||||
- "BASE_IMAGE=gitea.nulo.in/sutty/monit"
|
||||
password:
|
||||
from_secret: "DOCKER_PASSWORD"
|
||||
when:
|
||||
branch: antifascista
|
||||
event: push
|
||||
branch: "antifascista"
|
||||
event: "push"
|
||||
matrix:
|
||||
ALPINE_VERSION:
|
||||
- 3.17.0
|
||||
- 3.16.3
|
||||
- 3.15.6
|
||||
include:
|
||||
- ALPINE_VERSION: "3.20.3"
|
||||
- ALPINE_VERSION: "3.19.4"
|
||||
- ALPINE_VERSION: "3.18.9"
|
||||
- ALPINE_VERSION: "3.17.10"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ARG ALPINE_VERSION=3.13.6
|
||||
ARG BASE_IMAGE=sutty/monit
|
||||
ARG ALPINE_VERSION=3.18.3
|
||||
ARG BASE_IMAGE=gitea.nulo.in/sutty/monit
|
||||
FROM ${BASE_IMAGE}:${ALPINE_VERSION}
|
||||
MAINTAINER "f <f@sutty.nl>"
|
||||
LABEL org.opencontainers.image.authors="f@sutty.nl"
|
||||
|
||||
ENV BORG_HOST_ID borg
|
||||
ENV BORG_PASSPHRASE ""
|
||||
|
@ -11,7 +11,7 @@ ENV SSH_SERVER ""
|
|||
ENV SSH_USER root
|
||||
ENV SSH_PORT 22
|
||||
|
||||
RUN apk add --no-cache borgbackup openssh-client
|
||||
RUN apk add --no-cache borgbackup openssh-client zulip-client
|
||||
|
||||
COPY ./monit.conf /etc/monit.d/borg.conf
|
||||
COPY ./backup.sh /usr/local/bin/backup
|
||||
|
|
33
backup.sh
33
backup.sh
|
@ -1,19 +1,31 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Password can't be empty
|
||||
test -n "${BORG_PASSPHRASE}"
|
||||
test -n "${DEST}"
|
||||
test -n "${SSH_ALIAS}"
|
||||
|
||||
# Defaults
|
||||
SSH_PORT="${SSH_PORT:-22}"
|
||||
SSH_SERVER="${SSH_SERVER:-${SSH_ALIAS}}"
|
||||
SSH_USER="${SSH_USER:-root}"
|
||||
|
||||
umask 077
|
||||
|
||||
DATE="$(date +%F)"
|
||||
ORIG=/srv/data
|
||||
|
||||
if ! grep -q "${SSH_ALIAS}" /root/.ssh/config ; then
|
||||
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
|
||||
echo " Port ${SSH_PORT:-22}" >> /root/.ssh/config
|
||||
echo " HostName ${SSH_SERVER:-${SSH_ALIAS}}" >> /root/.ssh/config
|
||||
echo " User ${SSH_USER:-root}" >> /root/.ssh/config
|
||||
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
|
||||
echo " Port ${SSH_PORT}" >> /root/.ssh/config
|
||||
echo " HostName ${SSH_SERVER}" >> /root/.ssh/config
|
||||
echo " User ${SSH_USER}" >> /root/.ssh/config
|
||||
fi
|
||||
|
||||
touch /root/.ssh/known_hosts
|
||||
|
||||
if ! ssh-keygen -F "[${SSH_SERVER}]:${SSH_PORT}"; then
|
||||
echo "${SSH_KNOWN_HOSTS}" >> /root/.ssh/known_hosts
|
||||
fi
|
||||
|
||||
ssh -fN ${SSH_ALIAS}
|
||||
|
@ -23,8 +35,13 @@ for signal in TERM QUIT HUP EXIT INT KILL; do
|
|||
done
|
||||
|
||||
# It'll fail the second time
|
||||
borg init --encryption=repokey "${SSH_ALIAS}:${DEST}" || :
|
||||
borg create -v --stats "${SSH_ALIAS}:${DEST}::${DATE}" "${ORIG}"
|
||||
borg prune -v --stats --keep-daily ${KEEP} "${SSH_ALIAS}:${DEST}"
|
||||
borg init --encryption=repokey "${SSH_ALIAS}:${DEST}" 2>&1 | tee /tmp/backup.log
|
||||
borg create -v --stats "${SSH_ALIAS}:${DEST}::${DATE}" "${ORIG}" 2>&1 | tee -a /tmp/backup.log
|
||||
borg prune -v --stats --keep-daily ${KEEP} "${SSH_ALIAS}:${DEST}" 2>&1 | tee -a /tmp/backup.log
|
||||
borg list "${SSH_ALIAS}:${DEST}" 2>&1 | tee -a /tmp/backup.log
|
||||
|
||||
if test -n "${ZULIP_KEY}"; then
|
||||
cat /tmp/backup.log | zulip-client -u "${ZULIP_URL}" -b "${ZULIP_BOT}" -s "${ZULIP_STREAM}" -t "${ZULIP_TOPIC}"
|
||||
fi
|
||||
|
||||
exit $?
|
||||
|
|
|
@ -5,3 +5,4 @@ Host *
|
|||
VerifyHostKeyDNS yes
|
||||
HashKnownHosts yes
|
||||
StrictHostKeyChecking ask
|
||||
ForwardAgent yes
|
||||
|
|
Loading…
Reference in a new issue