fixed backups and expire command output

This commit is contained in:
Jarek Kowalski
2017-08-16 20:26:06 -07:00
parent 9634a798a8
commit 5fead928e0
2 changed files with 18 additions and 8 deletions

View File

@@ -95,13 +95,8 @@ func runBackupsCommand(context *kingpin.ParseContext) error {
sort.Sort(manifestSorter(manifests))
var lastTotalFileSize int64
for _, m := range manifests {
if m.Source != lastSource {
fmt.Printf("\n%v\n", m.Source)
lastSource = m.Source
count = 0
}
maybeIncomplete := ""
if m.IncompleteReason != "" {
if !*backupsIncludeIncomplete {
@@ -110,6 +105,13 @@ func runBackupsCommand(context *kingpin.ParseContext) error {
maybeIncomplete = " " + m.IncompleteReason
}
if m.Source != lastSource {
fmt.Printf("\n%v\n", m.Source)
lastSource = m.Source
count = 0
lastTotalFileSize = m.Stats.TotalFileSize
}
if count < *maxResultsPerPath {
fmt.Printf(
" %v%v %v %10v %v%v\n",
@@ -117,7 +119,7 @@ func runBackupsCommand(context *kingpin.ParseContext) error {
relPath,
m.StartTime.Format("2006-01-02 15:04:05 MST"),
units.BytesStringBase10(m.Stats.TotalFileSize),
deltaBytes(m.Stats.Repository.WrittenBytes),
deltaBytes(m.Stats.TotalFileSize-lastTotalFileSize),
maybeIncomplete,
)
if *backupsShowItemID {
@@ -130,6 +132,10 @@ func runBackupsCommand(context *kingpin.ParseContext) error {
}
count++
}
if m.IncompleteReason == "" || !*backupsIncludeIncomplete {
lastTotalFileSize = m.Stats.TotalFileSize
}
}
return nil
@@ -153,7 +159,7 @@ func deltaBytes(b int64) string {
return "(+" + units.BytesStringBase10(b) + ")"
}
return "(no change)"
return ""
}
func init() {

View File

@@ -68,6 +68,10 @@ func expireSnapshotsForSingleSource(snapshots []*snapshot.Manifest, pol *snapsho
}
}
if s.IncompleteReason != "" {
continue
}
if pol.Expiration.KeepLatest != nil {
registerSnapshot(fmt.Sprintf("%v", i), "latest", *pol.Expiration.KeepLatest)
}