2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-04 01:50:48 +00:00
restic/cmd/khepri/cmd_restore.go
2014-08-11 23:14:40 +02:00

36 lines
597 B
Go

package main
import (
"errors"
"log"
"github.com/fd0/khepri"
)
func commandRestore(repo *khepri.Repository, args []string) error {
if len(args) != 2 {
return errors.New("usage: restore ID dir")
}
id, err := khepri.ParseID(args[0])
if err != nil {
errx(1, "invalid id %q: %v", args[0], err)
}
target := args[1]
sn, err := khepri.LoadSnapshot(repo, id)
if err != nil {
log.Fatalf("error loading snapshot %s", id)
}
err = sn.RestoreAt(target)
if err != nil {
log.Fatalf("error restoring snapshot %s", id)
}
log.Printf("%q restored to %q\n", id, target)
return nil
}