KenKundert / emborg

Interactive command line interface to Borg Backup
GNU General Public License v3.0
94 stars 8 forks source link

"emborg --narrate create" with "check_after_create = 'latest'" prints entire output of "borg list" to stdout #60

Closed jjakob closed 2 years ago

jjakob commented 2 years ago

As described in the title, the entire output of borg list --prefix my-prefix- --json is printed to stdout when ran as emborg --narate create. This is a JSON list of all the backup archives that exist in the repository from this configuration (prefix). After some time a large number of archives will produce a lot of needless output on the console (or in my case, mails from the daily cronjob that are 150KB and increasing with every added archive).

I've traced it down to: https://github.com/KenKundert/emborg/blob/1264d25cc7d3e4d27abd4aa33bfd265b01c93842/emborg/command.py#L76 which is ran from get_name_of_latest_archive, from CheckCommand.run https://github.com/KenKundert/emborg/blob/1264d25cc7d3e4d27abd4aa33bfd265b01c93842/emborg/command.py#L392

I think there's no need to print the entire output of this command as emborg only needs its output internally to find the latest archive name. It does not fit into the expected output of "create".

KenKundert commented 2 years ago

I think of --narrate as a debugging option, and would never use it unless I was trying to debug a problem. Essentially it copies anything going to the log file to stdout as well. Under normal usage the narration is only saved to the log file. Perhaps consider running without the --narrate option.

jjakob commented 2 years ago

I thought --narrate was meant as a verbose replacement, I can't really do without it as I run emborg from a cronjob and want its output to get mailed to me via cron's mail, which captures the command's stdout/stderr. The format of narrate is good for this, just the list output takes up too much space, do you think it would be a big deal to not log it?

KenKundert commented 2 years ago

It is possible. I intended --narrate for debugging, but it is not heavily used for that and it does not add a lot of value over just looking in the logfile. However, it outputs a lot of things that are not really helpful if you are just looking for a more verbose output.

Emborg does support a --verbose flag, and a emborg create supports the --list, --progress, and --stats flags. I don't really know what you are looking for, so I am not sure what to suggest.

jjakob commented 2 years ago

emborg --verbose: outputs a list of every added file, too verbose (200MB stdout size!) emborg create --list: same as above ("list the files and directories as they are processed") emborg create --progress passes --progress to borg which displays a "live" progress updated several times a second, so it's not suitable to capture into an e-mail emborg create --stats may be suitable, as it prints just the stats of the latest archive, and prints progress information when starting a phase ("Running Borg create command ..., Checking archive ...")

So I think emborg create --stats is the most suitable for what I had in mind. It doesn't miss a lot of what --narrate had, and what it doesn't have, isn't important to me.

Thanks for the help, I consider this solved.