rustic-rs / rustic

rustic - fast, encrypted, and deduplicated backups powered by Rust
https://rustic.cli.rs
Apache License 2.0
1.76k stars 66 forks source link

Customize progress bars update #276

Closed borkd closed 1 year ago

borkd commented 1 year ago

Option to show progress info with given frequency as a line of text without control characters would be super useful. See restic's RESTIC_PROGRESS_FPS for the behavior I have in mind.

Option to force progress bars off altogether would work as an alternative when rustic is to be executed unattended under logged screen sessions. As of now session logfiles which take ~20 KiB each with restic use hundreds of megabytes each with rustic.

aawsome commented 1 year ago

As far as I know, the progress bars do not show at all when you are using a non-interactive terminal. I use a systemd service to run my backups and don't get progress bars in the logs. Can you describe your environment in more detail where you get the non-expected progress bars?

borkd commented 1 year ago

Logged (screen) sessions with full terminal emulation

aawsome commented 1 year ago

Mhh - if you use a standard terminal, the progress bars are shown... I hesitate a bit to add an option to rustic. In my opinion the standards defined by the indicatif crate should be ok, as this is exactly designed to provide progress bars and handle all kinds of edge cases...

Note that the progress bars are printed to stderr, so you can try to use rustic ... 2>/dev/null to get rid of the progress bars. This will also omit the logging output, but this you could also redirect to a file using --log-file.

Actually, I don't really see why you are using your logged screen sessions setup. Which benefit do you see to use this instead of an automated run? Or the other way round: which problem are you solving by using this setup?

borkd commented 1 year ago

I'm experimenting with rustic as a drop in replacement for restic in an existing workflow. Part of that workflow sets up the environment for restic. Besides running restic/rustic operations on repositories, their respective stdout and stderr is parsed to extract metrics which are then used elsewhere.

Having output limited to essential info and stats, or periodic status updates like in the restic's _FPS is super handy when processes run for days or even weeks and may have to be interactively inspected during troubleshooting

aawsome commented 1 year ago

About the metrics: Do you know that rustic stores a lot of metrics already in the snapshot? You can access them by using rustic snapshot <ID> --long or rustic snapshot <ID> --json. You can also get the metrics for all snapshots if you omit the <ID> in the above command. Also <ID> = latest is supported. Are there other metrics than the saved ones which you are missing?

borkd commented 1 year ago

Yes. Extra metadata stashed by rustic is handy, but does not cover everything I care about.

Switching between production/restic and testing/rustic also means I need to capture everythig I care about from restic runs too, at least until such functionality is adopted there

aawsome commented 1 year ago

279 adds the possibility to specify an interval for updating the progress bar. Note that you must specify a duration, e.g. 1s, 1m, 10ms instead of a FPS.

The default interval is still 100ms.

@borkd Can you test if #279 suits your needs?

aawsome commented 1 year ago

Disabling progress bars is not possible by #279 (but by using a non-interactive terminal or redirecting stderr). However, you can use a very long interval like 100y to get a similar effect.

borkd commented 1 year ago

@borkd Can you test if #279 suits your needs?

way more flexible, thanks!