func (kc *KopiaClient) SnapshotRestore(ctx context.Context, key string) ([]byte, error) {
	r, err := repo.Open(ctx, kc.configPath, kc.pw, &repo.Options{})
	if err != nil {
		return nil, errors.Wrap(err, "cannot open repository")
	}

	mans, err := kc.getSnapshotsFromKey(ctx, r, key)
	if err != nil {
		return nil, errors.Wrap(err, "cannot get snapshots from key")
	}

	man := kc.latestManifest(mans)
	rootOIDWithPath := man.RootObjectID().String() + "/" + dataFileName

	oid, err := snapshotfs.ParseObjectIDWithPath(ctx, r, rootOIDWithPath)
	if err != nil {
		return nil, errors.Wrapf(err, "cannot parse object ID %s", rootOIDWithPath)
	}

	or, err := r.OpenObject(ctx, oid)
	if err != nil {
		return nil, errors.Wrapf(err, "cannot open object %s", oid)
	}

	val, err := io.ReadAll(or)
	if err != nil {
		return nil, err
	}

	log.Printf("restored %v", units.BytesStringBase10(int64(len(val))))

	if err := r.Close(ctx); err != nil {
		return nil, err
	}

	return val, nil
}
// SnapshotRestore restores the latest snapshot for the given path.
SnapshotRestore restores the latest snapshot for the given path.
// SnapshotRestore restores the latest snapshot for the given path .
func (kc *KopiaClient) SnapshotRestore(ctx context.Context, key string) ([]byte, error) {
	r, err := repo.Open(ctx, kc.configPath, kc.pw, &repo.Options{})
	if err != nil {
		return nil, errors.Wrap(err, "cannot open repository")
	}
	mans, err := kc.getSnapshotsFromKey(ctx, r, key)
	if err != nil {
		return nil, errors.Wrap(err, "cannot get snapshots from key")
	}
	man := kc.latestManifest(mans)
	rootOIDWithPath := man.RootObjectID().String() + "/" + dataFileName
	oid, err := snapshotfs.ParseObjectIDWithPath(ctx, r, rootOIDWithPath)
	if err != nil {
		return nil, errors.Wrapf(err, "cannot parse object ID %s", rootOIDWithPath)
	}
	or, err := r.OpenObject(ctx, oid)
	if err != nil {
		return nil, errors.Wrapf(err, "cannot open object %s", oid)
	}
	val, err := io.ReadAll(or)
	if err != nil {
		return nil, err
	}
	log.Printf("restored %v", units.BytesStringBase10(int64(len(val))))
	if err := r.Close(ctx); err != nil {
		return nil, err
	}
	return val, nil
}
func ( kc * KopiaClient ) SnapshotRestore ( ctx context . Context , key string ) ( [ ] byte , error ) { r , err := repo . Open ( ctx , kc . configPath , kc . pw , & repo . Options { } ) if err != nil { return nil , errors . Wrap ( err , " " ) } mans , err := kc . getSnapshotsFromKey ( ctx , r , key ) if err != nil { return nil , errors . Wrap ( err , " " ) } man := kc . latestManifest ( mans ) rootOIDWithPath := man . RootObjectID ( ) . String ( ) + " " + dataFileName oid , err := snapshotfs . ParseObjectIDWithPath ( ctx , r , rootOIDWithPath ) if err != nil { return nil , errors . Wrapf ( err , " " , rootOIDWithPath ) } or , err := r . OpenObject ( ctx , oid ) if err != nil { return nil , errors . Wrapf ( err , " " , oid ) } val , err := io . ReadAll ( or ) if err != nil { return nil , err } log . Printf ( " " , units . BytesStringBase10 ( int64 ( len ( val ) ) ) ) if err := r . Close ( ctx ) ; err != nil { return nil , err } return val , nil }
SnapshotRestore restores the latest snapshot for the given path.
SnapshotRestore restores the latest snapshot for the given path .