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 |
5 changed files with 48 additions and 31 deletions
|
@ -1,23 +1,24 @@
|
||||||
pipeline:
|
steps:
|
||||||
publish:
|
publish:
|
||||||
image: plugins/docker
|
image: "docker.io/woodpeckerci/plugin-docker-buildx"
|
||||||
settings:
|
settings:
|
||||||
registry: registry.nulo.in
|
registry: "https://gitea.nulo.in"
|
||||||
username: sutty
|
username: "sutty"
|
||||||
repo: registry.nulo.in/sutty/borg
|
repo: "gitea.nulo.in/sutty/borg"
|
||||||
tags:
|
tags:
|
||||||
- ${ALPINE_VERSION}
|
- "${ALPINE_VERSION}"
|
||||||
- latest
|
- "latest"
|
||||||
build_args:
|
build_args:
|
||||||
- ALPINE_VERSION=${ALPINE_VERSION}
|
- "ALPINE_VERSION=${ALPINE_VERSION}"
|
||||||
- BASE_IMAGE=registry.nulo.in/sutty/monit
|
- "BASE_IMAGE=gitea.nulo.in/sutty/monit"
|
||||||
secrets:
|
password:
|
||||||
- docker_password
|
from_secret: "DOCKER_PASSWORD"
|
||||||
when:
|
when:
|
||||||
branch: antifascista
|
branch: "antifascista"
|
||||||
event: push
|
event: "push"
|
||||||
matrix:
|
matrix:
|
||||||
ALPINE_VERSION:
|
include:
|
||||||
- 3.17.0
|
- ALPINE_VERSION: "3.20.3"
|
||||||
- 3.16.3
|
- ALPINE_VERSION: "3.19.4"
|
||||||
- 3.15.6
|
- ALPINE_VERSION: "3.18.9"
|
||||||
|
- ALPINE_VERSION: "3.17.10"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
ARG ALPINE_VERSION=3.13.6
|
ARG ALPINE_VERSION=3.18.3
|
||||||
ARG BASE_IMAGE=sutty/monit
|
ARG BASE_IMAGE=gitea.nulo.in/sutty/monit
|
||||||
FROM ${BASE_IMAGE}:${ALPINE_VERSION}
|
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_HOST_ID borg
|
||||||
ENV BORG_PASSPHRASE ""
|
ENV BORG_PASSPHRASE ""
|
||||||
|
@ -11,7 +11,7 @@ ENV SSH_SERVER ""
|
||||||
ENV SSH_USER root
|
ENV SSH_USER root
|
||||||
ENV SSH_PORT 22
|
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 ./monit.conf /etc/monit.d/borg.conf
|
||||||
COPY ./backup.sh /usr/local/bin/backup
|
COPY ./backup.sh /usr/local/bin/backup
|
||||||
|
|
31
backup.sh
31
backup.sh
|
@ -1,19 +1,31 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
|
||||||
|
|
||||||
# Password can't be empty
|
# Password can't be empty
|
||||||
test -n "${BORG_PASSPHRASE}"
|
test -n "${BORG_PASSPHRASE}"
|
||||||
test -n "${DEST}"
|
test -n "${DEST}"
|
||||||
test -n "${SSH_ALIAS}"
|
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)"
|
DATE="$(date +%F)"
|
||||||
ORIG=/srv/data
|
ORIG=/srv/data
|
||||||
|
|
||||||
if ! grep -q "${SSH_ALIAS}" /root/.ssh/config ; then
|
if ! grep -q "${SSH_ALIAS}" /root/.ssh/config ; then
|
||||||
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
|
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
|
||||||
echo " Port ${SSH_PORT:-22}" >> /root/.ssh/config
|
echo " Port ${SSH_PORT}" >> /root/.ssh/config
|
||||||
echo " HostName ${SSH_SERVER:-${SSH_ALIAS}}" >> /root/.ssh/config
|
echo " HostName ${SSH_SERVER}" >> /root/.ssh/config
|
||||||
echo " User ${SSH_USER:-root}" >> /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
|
fi
|
||||||
|
|
||||||
ssh -fN ${SSH_ALIAS}
|
ssh -fN ${SSH_ALIAS}
|
||||||
|
@ -23,8 +35,13 @@ for signal in TERM QUIT HUP EXIT INT KILL; do
|
||||||
done
|
done
|
||||||
|
|
||||||
# It'll fail the second time
|
# It'll fail the second time
|
||||||
borg init --encryption=repokey "${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}"
|
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}"
|
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 $?
|
exit $?
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
set limits { programtimeout: 3000 s }
|
|
||||||
|
|
||||||
check program backup
|
check program backup
|
||||||
with path "/usr/local/bin/syslogize backup"
|
with path "/usr/local/bin/syslogize backup"
|
||||||
if status != 0 then alert
|
if status != 0 then alert
|
||||||
|
|
|
@ -5,3 +5,4 @@ Host *
|
||||||
VerifyHostKeyDNS yes
|
VerifyHostKeyDNS yes
|
||||||
HashKnownHosts yes
|
HashKnownHosts yes
|
||||||
StrictHostKeyChecking ask
|
StrictHostKeyChecking ask
|
||||||
|
ForwardAgent yes
|
||||||
|
|
Loading…
Reference in a new issue