Quiet not so quiet

I’ve run

restic backup --quiet  --json --exclude-file=/restic-exclude.txt /

but unfortunately it’s still printing out all the progress. It’s not printing the scan progress, but the upload.

Is there another flag I’ve missed or is this the intended behavior? Thanks

$ restic version
restic 0.12.1 compiled with go1.16.6 on linux/amd64

This was recently discussed in backup: --quiet ignored with --json · Issue #3553 · restic/restic · GitHub :slight_smile:

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.

1 Like

I just want the summary in JSON so I can push it to Zabbix and record how much data has been uploaded on every run.

Then just use/pipe it through jq (it’s awesome!) to grab the parts of the JSON you are interested in :smiley:

1 Like

Just for curiosity, here’s the command to filter out the summary record of a backup session:

root@abc:~# jq 'select(.message_type | test("summary"))' /tmp/restic-backup.json
{
  "message_type": "summary",
  "files_new": 280789,
  "files_changed": 322,
  "files_unmodified": 1291458,
  "dirs_new": 42859,
  "dirs_changed": 394,
  "dirs_unmodified": 372899,
  "data_blobs": 1526,
  "tree_blobs": 554,
  "data_added": 865951052,
  "total_files_processed": 1572569,
  "total_bytes_processed": 493588445732,
  "total_duration": 481.572991119,
  "snapshot_id": "7adad296"
}

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 :slight_smile:

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")'.

1 Like

Thanks, I used 'select(.message_type!="status")' filter to get everything but progress.

Indeed, with JSON it’s probably useless to filter messages, as it can be done later.