weird logging results #749

Closed
opened 2023-08-29 19:07:15 +00:00 by alsoeric · 2 comments

What I'm trying to do and why

I'm using ntfy.sh to notify me of failures in backup and I'm trying to record the actual backup outputs to syslog. in theory, the documentation says borgmatic should log to syslog if the shell is noninteractive but I've not been able to get to work.

Steps to reproduce

backup.sh is the script I use to run the backup. pw-config and home are the common and specific borgmatic config files.. I've tried various combinations of verbosity and syslog-verbosity what I don't get any output. However, when I explicitly write the output of borgmatic to syslog, then I get double entries

this code fragment creates double entries in syslog as shown in the example of actual behavior.

borgmatic --no-color --verbosity 1 --list --stats -c "$config_file" 2> "$temp_stderr" | {
    while IFS= read -r line; do
	    echo "$line" | logger -t bm-stdout-$config_name
    done
}

this code fragments and other variants with different values for velocity and syslog-verbosity create no entries in syslog
borgmatic --no-color --verbosity -2 --syslog-verbosity 1 --list --stats -c "$config_file" > /dev/null

Actual behavior

this is just a fragment of the entire log from a run but it demonstrates the problem. I'm getting duplicate entries, and one set of them have the wrong tag and preface each line with "ANSWER" or "WARNING"

Aug 29 14:25:49 lake borgmatic: ANSWER Repository: ssh://mumble.rsync.net
Aug 29 14:25:49 lake borgmatic: ANSWER Archive name: home-2023-08-29_14:25
Aug 29 14:25:49 lake borgmatic: ANSWER Archive fingerprint: 5d50a985d91c389bbb87e332bd0ec3aa9b5551899cf3056ab93b1d41d9f604c7
Aug 29 14:25:49 lake borgmatic: ANSWER Time (start): Tue, 2023-08-29 14:25:48
Aug 29 14:25:49 lake borgmatic: ANSWER Time (end): Tue, 2023-08-29 14:25:48
Aug 29 14:25:49 lake borgmatic: ANSWER Duration: 0.61 seconds
Aug 29 14:25:49 lake borgmatic: ANSWER Number of files: 3221
Aug 29 14:25:49 lake borgmatic: ANSWER Utilization of max. archive size: 0%
Aug 29 14:25:49 lake borgmatic: ANSWER ------------------------------------------------------------------------------
Aug 29 14:25:49 lake borgmatic: ANSWER Original size Compressed size Deduplicated size
Aug 29 14:25:49 lake borgmatic: ANSWER This archive: 64.58 MB 48.90 MB 1.81 kB
Aug 29 14:25:49 lake borgmatic: ANSWER All archives: 9.54 GB 8.67 GB 4.19 GB
Aug 29 14:25:49 lake borgmatic: ANSWER Unique chunks Total chunks
Aug 29 14:25:49 lake borgmatic: ANSWER Chunk index: 19021 70947
Aug 29 14:25:49 lake borgmatic: ANSWER ------------------------------------------------------------------------------
Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------
Aug 29 14:25:49 lake bm-stdout-home: Repository: ssh://mumble.rsync.net
Aug 29 14:25:49 lake bm-stdout-home: Archive name: home-2023-08-29_14:25
Aug 29 14:25:49 lake bm-stdout-home: Archive fingerprint: 5d50a985d91c389bbb87e332bd0ec3aa9b5551899cf3056ab93b1d41d9f604c7
Aug 29 14:25:49 lake bm-stdout-home: Time (start): Tue, 2023-08-29 14:25:48
Aug 29 14:25:49 lake bm-stdout-home: Time (end): Tue, 2023-08-29 14:25:48
Aug 29 14:25:49 lake bm-stdout-home: Duration: 0.61 seconds
Aug 29 14:25:49 lake bm-stdout-home: Number of files: 3221
Aug 29 14:25:49 lake bm-stdout-home: Utilization of max. archive size: 0%
Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------
Aug 29 14:25:49 lake bm-stdout-home: Original size Compressed size Deduplicated size
Aug 29 14:25:49 lake bm-stdout-home: This archive: 64.58 MB 48.90 MB 1.81 kB
Aug 29 14:25:49 lake bm-stdout-home: All archives: 9.54 GB 8.67 GB 4.19 GB
Aug 29 14:25:49 lake bm-stdout-home: Unique chunks Total chunks
Aug 29 14:25:49 lake bm-stdout-home: Chunk index: 19021 70947
Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------

Expected behavior

Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------
Aug 29 14:25:49 lake bm-stdout-home: Repository: ssh://mumble.rsync.net
Aug 29 14:25:49 lake bm-stdout-home: Archive name: home-2023-08-29_14:25
Aug 29 14:25:49 lake bm-stdout-home: Archive fingerprint: 5d50a985d91c389bbb87e332bd0ec3aa9b5551899cf3056ab93b1d41d9f604c7
Aug 29 14:25:49 lake bm-stdout-home: Time (start): Tue, 2023-08-29 14:25:48
Aug 29 14:25:49 lake bm-stdout-home: Time (end): Tue, 2023-08-29 14:25:48
Aug 29 14:25:49 lake bm-stdout-home: Duration: 0.61 seconds
Aug 29 14:25:49 lake bm-stdout-home: Number of files: 3221
Aug 29 14:25:49 lake bm-stdout-home: Utilization of max. archive size: 0%
Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------
Aug 29 14:25:49 lake bm-stdout-home: Original size Compressed size Deduplicated size
Aug 29 14:25:49 lake bm-stdout-home: This archive: 64.58 MB 48.90 MB 1.81 kB
Aug 29 14:25:49 lake bm-stdout-home: All archives: 9.54 GB 8.67 GB 4.19 GB
Aug 29 14:25:49 lake bm-stdout-home: Unique chunks Total chunks
Aug 29 14:25:49 lake bm-stdout-home: Chunk index: 19021 70947
Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------

Other notes / implementation ideas

No response

borgmatic version

borgmatic --version 1.8.1

borgmatic installation method

pip3

Borg version

borg --version borg 1.2.4

Python version

python3 --version Python 3.10.12

Database version (if applicable)

No response

Operating system and version

PRETTY_NAME="Ubuntu 22.04.3 LTS"

### What I'm trying to do and why I'm using ntfy.sh to notify me of failures in backup and I'm trying to record the actual backup outputs to syslog. in theory, the documentation says borgmatic should log to syslog if the shell is noninteractive but I've not been able to get to work. ### Steps to reproduce backup.sh is the script I use to run the backup. pw-config and home are the common and specific borgmatic config files.. I've tried various combinations of verbosity and syslog-verbosity what I don't get any output. However, when I explicitly write the output of borgmatic to syslog, then I get double entries this code fragment creates double entries in syslog as shown in the example of actual behavior. ``` borgmatic --no-color --verbosity 1 --list --stats -c "$config_file" 2> "$temp_stderr" | { while IFS= read -r line; do echo "$line" | logger -t bm-stdout-$config_name done } ``` this code fragments and other variants with different values for velocity and syslog-verbosity create no entries in syslog `borgmatic --no-color --verbosity -2 --syslog-verbosity 1 --list --stats -c "$config_file" > /dev/null ` ### Actual behavior this is just a fragment of the entire log from a run but it demonstrates the problem. I'm getting duplicate entries, and one set of them have the wrong tag and preface each line with "ANSWER" or "WARNING" Aug 29 14:25:49 lake borgmatic: ANSWER Repository: ssh://mumble.rsync.net Aug 29 14:25:49 lake borgmatic: ANSWER Archive name: home-2023-08-29_14:25 Aug 29 14:25:49 lake borgmatic: ANSWER Archive fingerprint: 5d50a985d91c389bbb87e332bd0ec3aa9b5551899cf3056ab93b1d41d9f604c7 Aug 29 14:25:49 lake borgmatic: ANSWER Time (start): Tue, 2023-08-29 14:25:48 Aug 29 14:25:49 lake borgmatic: ANSWER Time (end): Tue, 2023-08-29 14:25:48 Aug 29 14:25:49 lake borgmatic: ANSWER Duration: 0.61 seconds Aug 29 14:25:49 lake borgmatic: ANSWER Number of files: 3221 Aug 29 14:25:49 lake borgmatic: ANSWER Utilization of max. archive size: 0% Aug 29 14:25:49 lake borgmatic: ANSWER ------------------------------------------------------------------------------ Aug 29 14:25:49 lake borgmatic: ANSWER Original size Compressed size Deduplicated size Aug 29 14:25:49 lake borgmatic: ANSWER This archive: 64.58 MB 48.90 MB 1.81 kB Aug 29 14:25:49 lake borgmatic: ANSWER All archives: 9.54 GB 8.67 GB 4.19 GB Aug 29 14:25:49 lake borgmatic: ANSWER Unique chunks Total chunks Aug 29 14:25:49 lake borgmatic: ANSWER Chunk index: 19021 70947 Aug 29 14:25:49 lake borgmatic: ANSWER ------------------------------------------------------------------------------ Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------ Aug 29 14:25:49 lake bm-stdout-home: Repository: ssh://mumble.rsync.net Aug 29 14:25:49 lake bm-stdout-home: Archive name: home-2023-08-29_14:25 Aug 29 14:25:49 lake bm-stdout-home: Archive fingerprint: 5d50a985d91c389bbb87e332bd0ec3aa9b5551899cf3056ab93b1d41d9f604c7 Aug 29 14:25:49 lake bm-stdout-home: Time (start): Tue, 2023-08-29 14:25:48 Aug 29 14:25:49 lake bm-stdout-home: Time (end): Tue, 2023-08-29 14:25:48 Aug 29 14:25:49 lake bm-stdout-home: Duration: 0.61 seconds Aug 29 14:25:49 lake bm-stdout-home: Number of files: 3221 Aug 29 14:25:49 lake bm-stdout-home: Utilization of max. archive size: 0% Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------ Aug 29 14:25:49 lake bm-stdout-home: Original size Compressed size Deduplicated size Aug 29 14:25:49 lake bm-stdout-home: This archive: 64.58 MB 48.90 MB 1.81 kB Aug 29 14:25:49 lake bm-stdout-home: All archives: 9.54 GB 8.67 GB 4.19 GB Aug 29 14:25:49 lake bm-stdout-home: Unique chunks Total chunks Aug 29 14:25:49 lake bm-stdout-home: Chunk index: 19021 70947 Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------ ### Expected behavior Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------ Aug 29 14:25:49 lake bm-stdout-home: Repository: ssh://mumble.rsync.net Aug 29 14:25:49 lake bm-stdout-home: Archive name: home-2023-08-29_14:25 Aug 29 14:25:49 lake bm-stdout-home: Archive fingerprint: 5d50a985d91c389bbb87e332bd0ec3aa9b5551899cf3056ab93b1d41d9f604c7 Aug 29 14:25:49 lake bm-stdout-home: Time (start): Tue, 2023-08-29 14:25:48 Aug 29 14:25:49 lake bm-stdout-home: Time (end): Tue, 2023-08-29 14:25:48 Aug 29 14:25:49 lake bm-stdout-home: Duration: 0.61 seconds Aug 29 14:25:49 lake bm-stdout-home: Number of files: 3221 Aug 29 14:25:49 lake bm-stdout-home: Utilization of max. archive size: 0% Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------ Aug 29 14:25:49 lake bm-stdout-home: Original size Compressed size Deduplicated size Aug 29 14:25:49 lake bm-stdout-home: This archive: 64.58 MB 48.90 MB 1.81 kB Aug 29 14:25:49 lake bm-stdout-home: All archives: 9.54 GB 8.67 GB 4.19 GB Aug 29 14:25:49 lake bm-stdout-home: Unique chunks Total chunks Aug 29 14:25:49 lake bm-stdout-home: Chunk index: 19021 70947 Aug 29 14:25:49 lake bm-stdout-home: ------------------------------------------------------------------------------ ### Other notes / implementation ideas _No response_ ### borgmatic version # borgmatic --version 1.8.1 ### borgmatic installation method pip3 ### Borg version # borg --version borg 1.2.4 ### Python version # python3 --version Python 3.10.12 ### Database version (if applicable) _No response_ ### Operating system and version PRETTY_NAME="Ubuntu 22.04.3 LTS"
Owner

Thanks for filing this one. In the case of your script, I suspect you're getting doubled entries because borgmatic is (apparently) logging to syslog and you're redirecting stdout to syslog as well.

But for the second case of running borgmatic interactively, my guess is that borgmatic is detecting an interactive session and therefore refusing to log to syslog. I'm not sure exactly why your script isn't affected by this though. Maybe the act of piping makes it non-interactive.

Anyway, the workaround for now is to run borgmatic non-interactively (e.g., from a cron job or systemd service) if you want it to actually log to syslog. Ultimately, I think the fix is to implement something like #665, so even if borgmatic's behavior differs based on whether it's run interactively, the user can still choose to override things and force it to log to syslog. So feel free to weigh in on that ticket!

Thanks for filing this one. In the case of your script, I suspect you're getting doubled entries because borgmatic is (apparently) logging to syslog _and_ you're redirecting stdout to syslog as well. But for the second case of running borgmatic interactively, my guess is that borgmatic is detecting an interactive session and therefore refusing to log to syslog. I'm not sure exactly why your script isn't affected by this though. Maybe the act of piping makes it non-interactive. Anyway, the workaround for now is to run borgmatic non-interactively (e.g., from a cron job or systemd service) if you want it to actually log to syslog. Ultimately, I think the fix is to implement something like #665, so even if borgmatic's behavior differs based on whether it's run interactively, the user can still choose to override things and force it to log to syslog. So feel free to weigh in on that ticket!
witten added the
question / support
label 2023-09-16 23:02:31 +00:00
Owner

I think this one is answered, and any remaining work is in #665, but please let me know if that's not the case from your perspective.

I think this one is answered, and any remaining work is in #665, but please let me know if that's not the case from your perspective.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#749
No description provided.