backup: Tune user interface a bit

Make non-verbose mode a bit more verbose.
This commit is contained in:
Alexander Neumann 2018-05-01 22:02:48 +02:00
parent 8026e6fdfb
commit d0974c155d
2 changed files with 18 additions and 11 deletions

View File

@ -427,7 +427,7 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Termina
sc.Error = p.ScannerError sc.Error = p.ScannerError
sc.Result = p.ReportTotal sc.Result = p.ReportTotal
p.V("start scan") p.V("start scan on %v", targets)
t.Go(func() error { return sc.Scan(t.Context(gopts.ctx), targets) }) t.Go(func() error { return sc.Scan(t.Context(gopts.ctx), targets) })
arch := archiver.New(repo, targetFS, archiver.Options{}) arch := archiver.New(repo, targetFS, archiver.Options{})
@ -464,7 +464,7 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Termina
return uploader.Upload(gopts.ctx, t.Context(gopts.ctx), 30*time.Second) return uploader.Upload(gopts.ctx, t.Context(gopts.ctx), 30*time.Second)
}) })
p.V("start backup") p.V("start backup on %v", targets)
_, id, err := arch.Snapshot(gopts.ctx, targets, snapshotOpts) _, id, err := arch.Snapshot(gopts.ctx, targets, snapshotOpts)
if err != nil { if err != nil {
return err return err

View File

@ -329,7 +329,10 @@ func (b *Backup) ReportTotal(item string, s archiver.ScanStats) {
b.totalCh <- counter{Files: s.Files, Dirs: s.Dirs, Bytes: s.Bytes} b.totalCh <- counter{Files: s.Files, Dirs: s.Dirs, Bytes: s.Bytes}
if item == "" { if item == "" {
b.V("scan finished in %.3fs", time.Since(b.start).Seconds()) b.V("scan finished in %.3fs: %v files, %s",
time.Since(b.start).Seconds(),
s.Files, formatBytes(s.Bytes),
)
close(b.totalCh) close(b.totalCh)
return return
} }
@ -339,12 +342,16 @@ func (b *Backup) ReportTotal(item string, s archiver.ScanStats) {
func (b *Backup) Finish() { func (b *Backup) Finish() {
b.clearStatus <- struct{}{} b.clearStatus <- struct{}{}
b.V("processed %s in %s", formatBytes(b.totalBytes), formatDuration(time.Since(b.start))) b.P("\n")
b.V("\n") b.P("Files: %5d new, %5d changed, %5d unmodified\n", b.summary.Files.New, b.summary.Files.Changed, b.summary.Files.Unchanged)
b.V("Files: %5d new, %5d changed, %5d unmodified\n", b.summary.Files.New, b.summary.Files.Changed, b.summary.Files.Unchanged) b.P("Dirs: %5d new, %5d changed, %5d unmodified\n", b.summary.Dirs.New, b.summary.Dirs.Changed, b.summary.Dirs.Unchanged)
b.V("Dirs: %5d new, %5d changed, %5d unmodified\n", b.summary.Dirs.New, b.summary.Dirs.Changed, b.summary.Dirs.Unchanged) b.V("Data Blobs: %5d new\n", b.summary.ItemStats.DataBlobs)
b.VV("Data Blobs: %5d new\n", b.summary.ItemStats.DataBlobs) b.V("Tree Blobs: %5d new\n", b.summary.ItemStats.TreeBlobs)
b.VV("Tree Blobs: %5d new\n", b.summary.ItemStats.TreeBlobs) b.P("Added: %-5s\n", formatBytes(b.summary.ItemStats.DataSize+b.summary.ItemStats.TreeSize))
b.V("Added: %-5s\n", formatBytes(b.summary.ItemStats.DataSize+b.summary.ItemStats.TreeSize)) b.P("\n")
b.V("\n") b.P("processed %v files, %v in %s",
b.summary.Files.New+b.summary.Files.Changed+b.summary.Files.Unchanged,
formatBytes(b.totalBytes),
formatDuration(time.Since(b.start)),
)
} }