mirror of
https://github.com/kopia/kopia.git
synced 2026-03-12 19:26:25 -04:00
* logging: cleaned up stderr logging - do not show module - do not show timestamps by default (enable with --console-timestamps) * logging: replaced most printStderr() with log.Info * cli: additional logging cleanup
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
"github.com/kopia/kopia/repo/maintenance"
|
|
)
|
|
|
|
func maybeAutoUpgradeRepository(ctx context.Context, r repo.Repository) {
|
|
if r == nil {
|
|
return
|
|
}
|
|
|
|
mr, ok := r.(maintenance.MaintainableRepository)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
has, err := maintenance.HasParams(ctx, mr)
|
|
if err == nil && !has {
|
|
log(ctx).Noticef("Setting default maintenance parameters...")
|
|
|
|
if err := setDefaultMaintenanceParameters(ctx, mr); err != nil {
|
|
log(ctx).Warningf("unable to set default maintenance parameters: %v", err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func setDefaultMaintenanceParameters(ctx context.Context, rep maintenance.MaintainableRepository) error {
|
|
p := maintenance.DefaultParams()
|
|
p.Owner = rep.Username() + "@" + rep.Hostname()
|
|
|
|
if err := maintenance.SetParams(ctx, rep, &p); err != nil {
|
|
return errors.Wrap(err, "unable to set maintenance params")
|
|
}
|
|
|
|
log(ctx).Noticef(`
|
|
Kopia will perform quick maintenance of the repository automatically every %v
|
|
when running as %v. This operation never deletes any data.
|
|
|
|
Full maintenance (which also deletes unreferenced data) is disabled by default.
|
|
|
|
To run it manually use:
|
|
|
|
$ kopia maintenance run --full
|
|
|
|
Alternatively you can schedule full maintenance to run periodically using:
|
|
|
|
$ kopia maintenance set --enable-full=true --full-interval=4h
|
|
`, p.QuickCycle.Interval, p.Owner)
|
|
|
|
return nil
|
|
}
|