Files
kopia/cli/command_snapshot_gc.go
Julio Lopez 91508dac46 Move 'snapshot gc' functionality to gc package
Motivation:
Allow generalizing TreeWalker. See follow-up commit.

Changes:
* [x] Refactoring, no functional changes.
2019-11-06 17:34:28 -08:00

23 lines
676 B
Go

package cli
import (
"context"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/snapshot/gc"
)
var (
snapshotGCCommand = snapshotCommands.Command("gc", "Remove contents not used by any snapshot")
snapshotGCMinContentAge = snapshotGCCommand.Flag("min-age", "Minimum content age to allow deletion").Default("24h").Duration()
snapshotGCDelete = snapshotGCCommand.Flag("delete", "Delete unreferenced contents").Bool()
)
func runSnapshotGCCommand(ctx context.Context, rep *repo.Repository) error {
return gc.Run(ctx, rep, *snapshotGCMinContentAge, *snapshotGCDelete)
}
func init() {
snapshotGCCommand.Action(repositoryAction(runSnapshotGCCommand))
}