2
2
mirror of https://github.com/octoleo/restic.git synced 2024-09-21 19:39:01 +00:00
restic/cmd/restic/cmd_cache.go
2015-06-21 17:40:22 +02:00

49 lines
789 B
Go

package main
import (
"fmt"
"github.com/restic/restic"
)
type CmdCache struct{}
func init() {
_, err := parser.AddCommand("cache",
"manage cache",
"The cache command creates and manages the local cache",
&CmdCache{})
if err != nil {
panic(err)
}
}
func (cmd CmdCache) Usage() string {
return "[update|clear]"
}
func (cmd CmdCache) Execute(args []string) error {
// if len(args) == 0 || len(args) > 2 {
// return fmt.Errorf("wrong number of parameters, Usage: %s", cmd.Usage())
// }
s, err := OpenRepo()
if err != nil {
return err
}
cache, err := restic.NewCache(s, mainOpts.CacheDir)
if err != nil {
return err
}
fmt.Printf("clear cache for old snapshots\n")
err = cache.Clear(s)
if err != nil {
return err
}
fmt.Printf("done\n")
return nil
}