What is the use case of specifying these two options (--quiet and --json ) at the same time? If you don’t want output, you specify --quiet and have no reason to specify --json , and vice versa if you want JSON output you specify --json and have no reason to specify --quiet.
I was wondering: wouldn’t it be helpful to have the error_count item in summary, would it? Also, having an array of error messages could come handy, i.e. knowing which errors occured.
Glad you figured it out! Here’s a backup run where one file couldn’t be read:
$ ./restic -r apa/ backup --json foo2/
{"message_type":"status","percent_done":0,"total_files":1}
{"message_type":"error","error":{"Op":"open","Path":"foo2/blah.txt","Err":13},"during":"archival","item":"/Users/USER/foo2/blah.txt"}
{"message_type":"summary","files_new":0,"files_changed":0,"files_unmodified":2,"dirs_new":0,"dirs_changed":0,"dirs_unmodified":1,"data_blobs":0,"tree_blobs":0,"data_added":0,"total_files_processed":2,"total_bytes_processed":170213,"total_duration":0.305376044,"snapshot_id":"08e9261a"}
Warning: at least one source file could not be read
As you can see there’s already an error entry output, so I think if you’re a consumer of JSON you’d just check for that. But maybe it would be good to have in a summary. File a PR if you wish
By the way, you can use this syntax for jq if you want to shorten it a bit: restic ... backup --json ... | jq 'select(.message_type=="summary")'.