I would like to log what happened during a backup or forget command, in particular when run automatically via systemd. But also for a manual run, because it then behaves the same no matter if I start it or systemd. To this end, I use these options (simplified):
However, these commands, I have no output on the command line and for longer backups I cannot see what the command is doing. Is there a way around that?
One idea (which would be a feature request probably) is this: there could be a --log-file option to indicate where a log file is created. Something like:
would then show the normal command line output but write the json output to the given file.
As long as this is not implemented, can I retrieve the same information that --json writes also from a restic diff output without creating log files during backup?
Summary
Is there a way to get both json and plain text output simultaneously
Would that be a reasonable feature request?
Can I get the same information from restic diff or any other command?
Sorry, I didn’t quite catch that that was the main requirement, just thought that seeing the json output on stdout would be good enough to see how the command is progressing…
The suggested --log-file feature is hardly a priority at this point, and I can’t recall anyone else asking for it either so it doesn’t seem like a pressing need. And if it were to exist, it would then have to be established how one is supposed to configure that the log file is supposed to be JSON and not plain text, while at the same time one wants either of those on the standard output. I just don’t see this being something worth considering right now, honestly.
An even better solution would be to have the backup metadata (like added size, backup duration) already to the snapshot as asked for in the forum thread below. Then json log files would not be necessary.
Look up the logs using journalctl -u then. With --follow you can even watch them live. Be aware though, that with high verbosity journald will ratelimit and drop a lot of lines.
There is tee which will take stdin and write it to stdoutand the given file.
$ restic backup … | grep summary | tee ~/resticlogs/backup_$(date).json
Thanks, I know tee. That’s not the point. If I do a manual backup, I like the updating progress where I can see which files are currently processed. But I want to know the backup duration etc. which is provided only by the backup command and afaik not in the snapshot metadata.
Now, I have to do this tee thing to logfiles (and not just restic backup) and if I want to see the files flying by, I have to parse the text output instead of using --json and a json parser. For backup monitoring it would be much easier if the summary data (duration, data added) was stored with the snapshots.
I have not tested it, but I don’t think so as the error section and the summary section are part of the JSON output of a backup, but only the summary object is part of the snapshot JSON data.