Files
kopia/cli/command_snapshot_restore.go
Jarek Kowalski 6cb9b8fa4f repo: refactored public API (#318)
* This is 99% mechanical:

Extracted repo.Repository interface that only exposes high-level object and manifest management methods, but not blob nor content management.

Renamed old *repo.Repository to *repo.DirectRepository

Reviewed codebase to only depend on repo.Repository as much as possible, but added way for low-level CLI commands to use DirectRepository.

* PR fixes
2020-03-26 08:04:01 -07:00

25 lines
885 B
Go

package cli
import (
"context"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/manifest"
"github.com/kopia/kopia/snapshot/snapshotfs"
)
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()
snapshotRestoreTargetPath = snapshotRestoreCommand.Arg("target-path", "Path of the directory for the contents to be restored").Required().String()
)
func runSnapRestoreCommand(ctx context.Context, rep repo.Repository) error {
return snapshotfs.Restore(ctx, rep, *snapshotRestoreTargetPath, manifest.ID(*snapshotRestoreSnapID), restoreOptions())
}
func init() {
addRestoreFlags(snapshotRestoreCommand)
snapshotRestoreCommand.Action(repositoryAction(runSnapRestoreCommand))
}