forked from TrueCloudLab/restic
Merge pull request #3286 from MichaelEischer/fix-quiet-backup
backup: Correctly handle --quiet flag
This commit is contained in:
commit
8eb6a5805b
3 changed files with 16 additions and 5 deletions
11
changelog/unreleased/issue-3284
Normal file
11
changelog/unreleased/issue-3284
Normal file
|
@ -0,0 +1,11 @@
|
|||
Bugfix: `backup --quiet` no longer prints status information
|
||||
|
||||
A regression in the latest restic version caused the output of `backup --quiet`
|
||||
to contain large amounts of backup progress information when run using an
|
||||
interactive terminal. This is fixed now.
|
||||
|
||||
A workaround for this bug is to run restic as follows:
|
||||
`restic backup --quiet [..] | cat -`.
|
||||
|
||||
https://github.com/restic/restic/issues/3184
|
||||
https://github.com/restic/restic/pull/3186
|
|
@ -561,7 +561,7 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Termina
|
|||
}()
|
||||
gopts.stdout, gopts.stderr = p.Stdout(), p.Stderr()
|
||||
|
||||
p.SetMinUpdatePause(calculateProgressInterval())
|
||||
p.SetMinUpdatePause(calculateProgressInterval(!gopts.Quiet))
|
||||
|
||||
t.Go(func() error { return p.Run(t.Context(gopts.ctx)) })
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
|
||||
// calculateProgressInterval returns the interval configured via RESTIC_PROGRESS_FPS
|
||||
// or if unset returns an interval for 60fps on interactive terminals and 0 (=disabled)
|
||||
// for non-interactive terminals
|
||||
func calculateProgressInterval() time.Duration {
|
||||
// for non-interactive terminals or when run using the --quiet flag
|
||||
func calculateProgressInterval(show bool) time.Duration {
|
||||
interval := time.Second / 60
|
||||
fps, err := strconv.ParseFloat(os.Getenv("RESTIC_PROGRESS_FPS"), 64)
|
||||
if err == nil && fps > 0 {
|
||||
|
@ -20,7 +20,7 @@ func calculateProgressInterval() time.Duration {
|
|||
fps = 60
|
||||
}
|
||||
interval = time.Duration(float64(time.Second) / fps)
|
||||
} else if !stdoutIsTerminal() {
|
||||
} else if !stdoutIsTerminal() || !show {
|
||||
interval = 0
|
||||
}
|
||||
return interval
|
||||
|
@ -31,7 +31,7 @@ func newProgressMax(show bool, max uint64, description string) *progress.Counter
|
|||
if !show {
|
||||
return nil
|
||||
}
|
||||
interval := calculateProgressInterval()
|
||||
interval := calculateProgressInterval(show)
|
||||
|
||||
return progress.New(interval, max, func(v uint64, max uint64, d time.Duration, final bool) {
|
||||
var status string
|
||||
|
|
Loading…
Reference in a new issue