Skip to content

Commit

Permalink
plugin rsnapshot_duration: avoid "broken pipe" errors from tac
Browse files Browse the repository at this point in the history
Consume the complete input from "tac".  Otherwise spammy error messages
would appear in the log.
  • Loading branch information
sumpfralle committed Sep 19, 2021
1 parent 818886b commit d314064
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/rsnapshot/rsnapshot_duration
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ RSNAPSHOT_DESCRIPTION=${rsnapshot_description:-Backup Duration}
get_latest_process_log() {
tac "$LOG_FILE" \
| awk '
BEGIN { in_process = 0; }
/ '"$RSNAPSHOT_OPERATION_NAME"': completed[, ]/ { in_process = 1; }
/ '"$RSNAPSHOT_OPERATION_NAME"': started$/ { if (in_process == 1) exit; }
BEGIN { in_process = 0; is_finished = 0; }
/ '"$RSNAPSHOT_OPERATION_NAME"': completed[, ]/ { if (is_finished == 0) in_process = 1; }
/ '"$RSNAPSHOT_OPERATION_NAME"': started$/ { if (in_process == 1) { in_process = 0; is_finished = 1; }}
{ if (in_process == 1) print($0); }' \
| tac
}
Expand All @@ -106,7 +106,7 @@ get_backups_with_duration() {
if [ -n "${backup_name:-}" ]; then
printf '%s\t%d\t%s\n' "$backup_name" "$((parsed_timestamp - backup_start))" "${backup_errors:-}"
fi
break
cat >/dev/null
fi
done | sort
}
Expand Down

0 comments on commit d314064

Please sign in to comment.