Skip to content

Commit

Permalink
Add --backup.clean.incremental.verbose flag (#7)
Browse files Browse the repository at this point in the history
This allow seeing exactly what incremental backup files would be
removed if `--backup.clean.incremental` was set.

Signed-off-by: Erik Swanson <[email protected]>
  • Loading branch information
eriksw authored Apr 5, 2019
1 parent 6e12fdf commit dc17a88
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions backup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ func (ch *incrementalCleanupHandler) Execute() error {
return nil
}
if cleanIncremental == nil || !*cleanIncremental {
lgr.Infow("skipping_incremental_cleanup", "reason", "not_enabled", "would_delete", len(ch.uploadedFiles))
lgr.Infow("skipping_incremental_cleanup", "reason", "not_enabled", "would_remove", len(ch.uploadedFiles))
if cleanIncrementalVerbose != nil && *cleanIncrementalVerbose {
for _, ref := range ch.uploadedFiles {
lgr.Infow("cleanup_would_have_removed_file", "name", ref.Name())
}
}
return nil
}

Expand All @@ -112,10 +117,15 @@ func (ch *incrementalCleanupHandler) Execute() error {
lgr.Errorw("cleanup_failed_to_remove_file", "name", ref.Name(), "err", err)
lastErr = err
} else {
lgr.Debugw("cleanup_removed_file", "name", ref.Name())
if cleanIncrementalVerbose != nil && *cleanIncrementalVerbose {
lgr.Infow("cleanup_removed_file", "name", ref.Name())
}
}
}
return lastErr
}

var cleanIncremental = kingpin.Flag("backup.clean.incremental", "Remove incremental backups that have been uploaded").Bool()
var (
cleanIncremental = kingpin.Flag("backup.clean.incremental", "Remove incremental backup files that have been uploaded.").Bool()
cleanIncrementalVerbose = kingpin.Flag("backup.clean.incremental.verbose", "Log incremental backup files that are or would be removed.").Bool()
)

0 comments on commit dc17a88

Please sign in to comment.