From 38b3243b4ccd2c93a4b933a0e93d1f16d8840e17 Mon Sep 17 00:00:00 2001 From: Gerard Bosch <30733556+gerardbosch@users.noreply.github.com> Date: Wed, 16 Feb 2022 13:51:28 +0100 Subject: [PATCH] Redirect stderr to systemd journal (#86) Errors were not written to the journal as systemd-cat was only reading stdin. Now, errors printed by restic are shown in the journal. --- usr/lib/systemd/system/restic-backup@.service | 2 +- usr/lib/systemd/system/restic-check@.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/lib/systemd/system/restic-backup@.service b/usr/lib/systemd/system/restic-backup@.service index c185521..deed180 100644 --- a/usr/lib/systemd/system/restic-backup@.service +++ b/usr/lib/systemd/system/restic-backup@.service @@ -12,4 +12,4 @@ Nice=10 Environment="HOME=/root" # The random sleep (in seconds) is in the case of multiple backup profiles. Many restic instances started at the same time could case high load or network bandwith usage. # `systemd-cat` allows showing the restic output to the systemd journal -ExecStart=bash -c 'ps cax | grep -q restic && sleep $(shuf -i 0-300 -n 1); source $INSTALL_PREFIX/etc/restic/%I.env.sh && $INSTALL_PREFIX/bin/restic_backup.sh | systemd-cat' +ExecStart=bash -c 'ps cax | grep -q restic && sleep $(shuf -i 0-300 -n 1); source $INSTALL_PREFIX/etc/restic/%I.env.sh && $INSTALL_PREFIX/bin/restic_backup.sh 2>&1 | systemd-cat' diff --git a/usr/lib/systemd/system/restic-check@.service b/usr/lib/systemd/system/restic-check@.service index edf7d28..9f5caf3 100644 --- a/usr/lib/systemd/system/restic-check@.service +++ b/usr/lib/systemd/system/restic-check@.service @@ -10,4 +10,4 @@ Conflicts=restic-backup.service Type=simple Nice=10 # `systemd-cat` allows showing the restic output to the systemd journal -ExecStart=bash -c 'source $INSTALL_PREFIX/etc/restic/%I.env.sh && $INSTALL_PREFIX/bin/restic_check.sh | systemd-cat' +ExecStart=bash -c 'source $INSTALL_PREFIX/etc/restic/%I.env.sh && $INSTALL_PREFIX/bin/restic_check.sh 2>&1 | systemd-cat'