From aa87ef296992091d1e783a7fd5c27894fa459eec Mon Sep 17 00:00:00 2001 From: napnap75 Date: Sun, 6 Oct 2024 15:20:35 +0200 Subject: [PATCH] Added runitor to handle HC pings --- restic-auto/Dockerfile | 7 +++++-- restic-auto/docker-entrypoint.sh | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/restic-auto/Dockerfile b/restic-auto/Dockerfile index 983ecba..e044f0d 100644 --- a/restic-auto/Dockerfile +++ b/restic-auto/Dockerfile @@ -7,11 +7,14 @@ RUN DOWNLOAD_ARCH=$(echo ${TARGETPLATFORM} | cut -d"/" -f 2) \ && DOWNLOAD_URL=$(curl -s https://api.github.com/repos/restic/restic/releases/latest | grep "browser_download_url" | grep "linux_"${DOWNLOAD_ARCH}"\." | cut -d\" -f4) \ && curl --retry 3 -L -s -o restic.bz2 ${DOWNLOAD_URL} \ && bunzip2 restic.bz2 \ - && chmod +x restic + && chmod +x restic \ + && DOWNLOAD_URL=$(curl -s https://api.github.com/repos/bdd/runitor/releases/latest | grep "browser_download_url" | grep "linux-"${DOWNLOAD_ARCH} | cut -d\" -f4) \ + && curl --retry 3 -L -s -o runitor ${DOWNLOAD_URL} \ + && chmod +x runitor FROM alpine:latest -COPY --from=builder restic /usr/bin/ +COPY --from=builder restic runitor /usr/bin/ RUN apk add --no-cache bash curl jq openssh-client dcron tzdata docker diff --git a/restic-auto/docker-entrypoint.sh b/restic-auto/docker-entrypoint.sh index 54aac7d..a83befc 100755 --- a/restic-auto/docker-entrypoint.sh +++ b/restic-auto/docker-entrypoint.sh @@ -37,7 +37,10 @@ else else echo -n "0 4 * * *" >> /tmp/crontab fi - echo -n " restic-auto >> /var/log/cron.log" >> /tmp/crontab + if [[ "$HC_PING_KEY" ]] ; then + echo -n " runitor -slug ${HOSTNAME}-restic-backup --" >> /tmp/crontab + fi + echo -n " restic-auto >> /var/log/cron.log" >> /tmp/crontab if [[ "$POST_BACKUP_COMMAND" ]] ; then echo -n " && $POST_BACKUP_COMMAND" >> /tmp/crontab fi @@ -47,7 +50,14 @@ else else echo -n "0 1 * * 0" >> /tmp/crontab fi - echo -n " restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 2 --prune >> /var/log/cron.log && restic check >> /var/log/cron.log" >> /tmp/crontab + if [[ "$HC_PING_KEY" ]] ; then + echo -n " runitor -slug ${HOSTNAME}-restic-forget --" >> /tmp/crontab + fi + echo -n " restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 2 --prune >> /var/log/cron.log &&" >> /tmp/crontab + if [[ "$HC_PING_KEY" ]] ; then + echo -n " runitor -slug ${HOSTNAME}-restic-check --" >> /tmp/crontab + fi + echo -n " restic check >> /var/log/cron.log" >> /tmp/crontab if [[ "$POST_MAINTENANCE_COMMAND" ]] ; then echo -n " && $POST_MAINTENANCE_COMMAND" >> /tmp/crontab fi