Compare commits

..

1 commit

Author SHA1 Message Date
a7c604b977 fix(monit): subir timeout
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
originalmente es 300s (5 min)
2023-02-16 18:31:34 +00:00
5 changed files with 31 additions and 48 deletions

View file

@ -1,24 +1,23 @@
steps: pipeline:
publish: publish:
image: "docker.io/woodpeckerci/plugin-docker-buildx" image: plugins/docker
settings: settings:
registry: "https://gitea.nulo.in" registry: registry.nulo.in
username: "sutty" username: sutty
repo: "gitea.nulo.in/sutty/borg" repo: registry.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=gitea.nulo.in/sutty/monit" - BASE_IMAGE=registry.nulo.in/sutty/monit
password: secrets:
from_secret: "DOCKER_PASSWORD" - docker_password
when: when:
branch: "antifascista" branch: antifascista
event: "push" event: push
matrix: matrix:
include: ALPINE_VERSION:
- ALPINE_VERSION: "3.20.3" - 3.17.0
- ALPINE_VERSION: "3.19.4" - 3.16.3
- ALPINE_VERSION: "3.18.9" - 3.15.6
- ALPINE_VERSION: "3.17.10"

View file

@ -1,7 +1,7 @@
ARG ALPINE_VERSION=3.18.3 ARG ALPINE_VERSION=3.13.6
ARG BASE_IMAGE=gitea.nulo.in/sutty/monit ARG BASE_IMAGE=sutty/monit
FROM ${BASE_IMAGE}:${ALPINE_VERSION} 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_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 zulip-client RUN apk add --no-cache borgbackup openssh-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

View file

@ -1,31 +1,19 @@
#!/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}" >> /root/.ssh/config echo " Port ${SSH_PORT:-22}" >> /root/.ssh/config
echo " HostName ${SSH_SERVER}" >> /root/.ssh/config echo " HostName ${SSH_SERVER:-${SSH_ALIAS}}" >> /root/.ssh/config
echo " User ${SSH_USER}" >> /root/.ssh/config echo " User ${SSH_USER:-root}" >> /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}
@ -35,13 +23,8 @@ 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}" 2>&1 | tee /tmp/backup.log borg init --encryption=repokey "${SSH_ALIAS}:${DEST}" || :
borg create -v --stats "${SSH_ALIAS}:${DEST}::${DATE}" "${ORIG}" 2>&1 | tee -a /tmp/backup.log borg create -v --stats "${SSH_ALIAS}:${DEST}::${DATE}" "${ORIG}"
borg prune -v --stats --keep-daily ${KEEP} "${SSH_ALIAS}:${DEST}" 2>&1 | tee -a /tmp/backup.log borg prune -v --stats --keep-daily ${KEEP} "${SSH_ALIAS}:${DEST}"
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 $?

View file

@ -1,3 +1,5 @@
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

View file

@ -5,4 +5,3 @@ Host *
VerifyHostKeyDNS yes VerifyHostKeyDNS yes
HashKnownHosts yes HashKnownHosts yes
StrictHostKeyChecking ask StrictHostKeyChecking ask
ForwardAgent yes