Files
kopia/cli/command_maintenance_run.go
Jarek Kowalski 960c33475e maintenance: disabled automatic compaction on repository opening
instead moved to run as part of maintenance ('kopia maintenance run')

added 'kopia maintenance run --force' flag which runs maintenance even
if not owned
2020-06-01 00:57:32 -07:00

29 lines
826 B
Go

package cli
import (
"context"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/maintenance"
"github.com/kopia/kopia/snapshot/snapshotmaintenance"
)
var (
maintenanceRunCommand = maintenanceCommands.Command("run", "Run repository maintenance").Default()
maintenanceRunFull = maintenanceRunCommand.Flag("full", "Full maintenance").Bool()
maintenanceRunForce = maintenanceRunCommand.Flag("force", "Run maintenance even if not owned (unsafe)").Hidden().Bool()
)
func runMaintenanceCommand(ctx context.Context, rep *repo.DirectRepository) error {
mode := maintenance.ModeQuick
if *maintenanceRunFull {
mode = maintenance.ModeFull
}
return snapshotmaintenance.Run(ctx, rep, mode, *maintenanceRunForce)
}
func init() {
maintenanceRunCommand.Action(directRepositoryAction(runMaintenanceCommand))
}