From 5ca9ecfe2afdb2304c9a21fe8fefb8316f036bb7 Mon Sep 17 00:00:00 2001 From: Nick Stokoe Date: Tue, 27 May 2025 18:18:06 +0100 Subject: [PATCH] templates/docker-compose/borgmatic/ - avoid losing STDERR lines use stdbuf to change the buffereing mode to be linewise --- templates/docker-compose/borgmatic/Dockerfile | 7 +++++++ templates/docker-compose/borgmatic/backup.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/templates/docker-compose/borgmatic/Dockerfile b/templates/docker-compose/borgmatic/Dockerfile index 5af8ab1..b39d1c5 100644 --- a/templates/docker-compose/borgmatic/Dockerfile +++ b/templates/docker-compose/borgmatic/Dockerfile @@ -1,4 +1,11 @@ FROM b3vis/borgmatic:latest-msmtp +# Install stdbuf, used by backup.sh +RUN \ + echo "* Installing Runtime Packages" \ + && apk upgrade --no-cache \ + && echo "* Installing Runtime Packages" \ + && apk add -U --no-cache \ + coreutils COPY --chmod=755 backup.sh /backup.sh diff --git a/templates/docker-compose/borgmatic/backup.sh b/templates/docker-compose/borgmatic/backup.sh index 102a781..06a426d 100755 --- a/templates/docker-compose/borgmatic/backup.sh +++ b/templates/docker-compose/borgmatic/backup.sh @@ -31,7 +31,7 @@ indent() { log() { # Adapted from https://stackoverflow.com/a/31151808 { - "$@" 2>&1 1>&3 3>&- | indent " ! " + stdbuf -oL -eL "$@" 2>&1 1>&3 3>&- | indent " ! " } 3>&1 1>&2 | indent " | " | tee -a "$LOGFILE" }