mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Merge pull request #3286 from MichaelEischer/fix-quiet-backup
backup: Correctly handle --quiet flag
This commit is contained in:
commit
8eb6a5805b
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()
|
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)) })
|
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
|
// calculateProgressInterval returns the interval configured via RESTIC_PROGRESS_FPS
|
||||||
// or if unset returns an interval for 60fps on interactive terminals and 0 (=disabled)
|
// or if unset returns an interval for 60fps on interactive terminals and 0 (=disabled)
|
||||||
// for non-interactive terminals
|
// for non-interactive terminals or when run using the --quiet flag
|
||||||
func calculateProgressInterval() time.Duration {
|
func calculateProgressInterval(show bool) time.Duration {
|
||||||
interval := time.Second / 60
|
interval := time.Second / 60
|
||||||
fps, err := strconv.ParseFloat(os.Getenv("RESTIC_PROGRESS_FPS"), 64)
|
fps, err := strconv.ParseFloat(os.Getenv("RESTIC_PROGRESS_FPS"), 64)
|
||||||
if err == nil && fps > 0 {
|
if err == nil && fps > 0 {
|
||||||
@ -20,7 +20,7 @@ func calculateProgressInterval() time.Duration {
|
|||||||
fps = 60
|
fps = 60
|
||||||
}
|
}
|
||||||
interval = time.Duration(float64(time.Second) / fps)
|
interval = time.Duration(float64(time.Second) / fps)
|
||||||
} else if !stdoutIsTerminal() {
|
} else if !stdoutIsTerminal() || !show {
|
||||||
interval = 0
|
interval = 0
|
||||||
}
|
}
|
||||||
return interval
|
return interval
|
||||||
@ -31,7 +31,7 @@ func newProgressMax(show bool, max uint64, description string) *progress.Counter
|
|||||||
if !show {
|
if !show {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
interval := calculateProgressInterval()
|
interval := calculateProgressInterval(show)
|
||||||
|
|
||||||
return progress.New(interval, max, func(v uint64, max uint64, d time.Duration, final bool) {
|
return progress.New(interval, max, func(v uint64, max uint64, d time.Duration, final bool) {
|
||||||
var status string
|
var status string
|
||||||
|
Loading…
Reference in New Issue
Block a user