Compare commits
1 commit
antifascis
...
aumentar-t
Author | SHA1 | Date | |
---|---|---|---|
a7c604b977 |
5 changed files with 31 additions and 48 deletions
|
@ -1,24 +1,23 @@
|
|||
steps:
|
||||
pipeline:
|
||||
publish:
|
||||
image: "docker.io/woodpeckerci/plugin-docker-buildx"
|
||||
image: plugins/docker
|
||||
settings:
|
||||
registry: "https://gitea.nulo.in"
|
||||
username: "sutty"
|
||||
repo: "gitea.nulo.in/sutty/borg"
|
||||
registry: registry.nulo.in
|
||||
username: sutty
|
||||
repo: registry.nulo.in/sutty/borg
|
||||
tags:
|
||||
- "${ALPINE_VERSION}"
|
||||
- "latest"
|
||||
- ${ALPINE_VERSION}
|
||||
- latest
|
||||
build_args:
|
||||
- "ALPINE_VERSION=${ALPINE_VERSION}"
|
||||
- "BASE_IMAGE=gitea.nulo.in/sutty/monit"
|
||||
password:
|
||||
from_secret: "DOCKER_PASSWORD"
|
||||
- ALPINE_VERSION=${ALPINE_VERSION}
|
||||
- BASE_IMAGE=registry.nulo.in/sutty/monit
|
||||
secrets:
|
||||
- docker_password
|
||||
when:
|
||||
branch: "antifascista"
|
||||
event: "push"
|
||||
branch: antifascista
|
||||
event: push
|
||||
matrix:
|
||||
include:
|
||||
- ALPINE_VERSION: "3.20.3"
|
||||
- ALPINE_VERSION: "3.19.4"
|
||||
- ALPINE_VERSION: "3.18.9"
|
||||
- ALPINE_VERSION: "3.17.10"
|
||||
ALPINE_VERSION:
|
||||
- 3.17.0
|
||||
- 3.16.3
|
||||
- 3.15.6
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ARG ALPINE_VERSION=3.18.3
|
||||
ARG BASE_IMAGE=gitea.nulo.in/sutty/monit
|
||||
ARG ALPINE_VERSION=3.13.6
|
||||
ARG BASE_IMAGE=sutty/monit
|
||||
FROM ${BASE_IMAGE}:${ALPINE_VERSION}
|
||||
LABEL org.opencontainers.image.authors="f@sutty.nl"
|
||||
MAINTAINER "f <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 zulip-client
|
||||
RUN apk add --no-cache borgbackup openssh-client
|
||||
|
||||
COPY ./monit.conf /etc/monit.d/borg.conf
|
||||
COPY ./backup.sh /usr/local/bin/backup
|
||||
|
|
33
backup.sh
33
backup.sh
|
@ -1,31 +1,19 @@
|
|||
#!/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}" >> /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
|
||||
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
|
||||
fi
|
||||
|
||||
ssh -fN ${SSH_ALIAS}
|
||||
|
@ -35,13 +23,8 @@ for signal in TERM QUIT HUP EXIT INT KILL; do
|
|||
done
|
||||
|
||||
# It'll fail the second time
|
||||
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
|
||||
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}"
|
||||
|
||||
exit $?
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
set limits { programtimeout: 3000 s }
|
||||
|
||||
check program backup
|
||||
with path "/usr/local/bin/syslogize backup"
|
||||
if status != 0 then alert
|
||||
|
|
|
@ -5,4 +5,3 @@ Host *
|
|||
VerifyHostKeyDNS yes
|
||||
HashKnownHosts yes
|
||||
StrictHostKeyChecking ask
|
||||
ForwardAgent yes
|
||||
|
|
Loading…
Reference in a new issue