Files
kopia/cli/command_snapshot_restore.go
Jarek Kowalski 8ead49b779 restore: support for zip, tar and tar.gz restore outputs (#482)
* restore: support for zip, tar and tar.gz restore outputs

Moved restore functionality to its own package.

* Fix enum values in the 'mode' flag

Co-authored-by: Julio López <julio+gh@kasten.io>
2020-07-22 22:56:11 -07:00

38 lines
898 B
Go

package cli
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/manifest"
"github.com/kopia/kopia/snapshot/restore"
)
var (
snapshotRestoreCommand = snapshotCommands.Command("restore", "Restore a snapshot from the snapshot ID to the given target path")
snapshotRestoreSnapID = snapshotRestoreCommand.Arg("id", "Snapshot ID to be restored").Required().String()
)
func runSnapRestoreCommand(ctx context.Context, rep repo.Repository) error {
output, err := restoreOutput()
if err != nil {
return errors.Wrap(err, "unable to initialize output")
}
st, err := restore.Snapshot(ctx, rep, output, manifest.ID(*snapshotRestoreSnapID))
if err != nil {
return err
}
printRestoreStats(st)
return nil
}
func init() {
addRestoreFlags(snapshotRestoreCommand)
snapshotRestoreCommand.Action(repositoryAction(runSnapRestoreCommand))
}