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

	ctx, rw, err := r.NewWriter(ctx, repo.WriteSessionOptions{})
	if err != nil {
		return errors.Wrap(err, "cannot get new repository writer")
	}

	si := kc.getSourceInfoFromKey(r, key)

	policyTree, err := policy.TreeForSource(ctx, r, si)
	if err != nil {
		return errors.Wrap(err, "cannot get policy tree for source")
	}

	source := kc.getSourceForKeyVal(key, val)
	u := snapshotfs.NewUploader(rw)

	man, err := u.Upload(ctx, source, policyTree, si)
	if err != nil {
		return errors.Wrap(err, "cannot get manifest")
	}

	log.Printf("snapshotting %v", units.BytesStringBase10(atomic.LoadInt64(&man.Stats.TotalFileSize)))

	if _, err := snapshot.SaveSnapshot(ctx, rw, man); err != nil {
		return errors.Wrap(err, "cannot save snapshot")
	}

	if err := rw.Flush(ctx); err != nil {
		return err
	}

	return r.Close(ctx)
}
// SnapshotCreate creates a snapshot for the given path.
SnapshotCreate creates a snapshot for the given path.
// SnapshotCreate creates a snapshot for the given path .
func (kc *KopiaClient) SnapshotCreate(ctx context.Context, key string, val []byte) error {
	r, err := repo.Open(ctx, kc.configPath, kc.pw, &repo.Options{})
	if err != nil {
		return errors.Wrap(err, "cannot open repository")
	}
	ctx, rw, err := r.NewWriter(ctx, repo.WriteSessionOptions{})
	if err != nil {
		return errors.Wrap(err, "cannot get new repository writer")
	}
	si := kc.getSourceInfoFromKey(r, key)
	policyTree, err := policy.TreeForSource(ctx, r, si)
	if err != nil {
		return errors.Wrap(err, "cannot get policy tree for source")
	}
	source := kc.getSourceForKeyVal(key, val)
	u := snapshotfs.NewUploader(rw)
	man, err := u.Upload(ctx, source, policyTree, si)
	if err != nil {
		return errors.Wrap(err, "cannot get manifest")
	}
	log.Printf("snapshotting %v", units.BytesStringBase10(atomic.LoadInt64(&man.Stats.TotalFileSize)))
	if _, err := snapshot.SaveSnapshot(ctx, rw, man); err != nil {
		return errors.Wrap(err, "cannot save snapshot")
	}
	if err := rw.Flush(ctx); err != nil {
		return err
	}
	return r.Close(ctx)
}
func ( kc * KopiaClient ) SnapshotCreate ( ctx context . Context , key string , val [ ] byte ) error { r , err := repo . Open ( ctx , kc . configPath , kc . pw , & repo . Options { } ) if err != nil { return errors . Wrap ( err , " " ) } ctx , rw , err := r . NewWriter ( ctx , repo . WriteSessionOptions { } ) if err != nil { return errors . Wrap ( err , " " ) } si := kc . getSourceInfoFromKey ( r , key ) policyTree , err := policy . TreeForSource ( ctx , r , si ) if err != nil { return errors . Wrap ( err , " " ) } source := kc . getSourceForKeyVal ( key , val ) u := snapshotfs . NewUploader ( rw ) man , err := u . Upload ( ctx , source , policyTree , si ) if err != nil { return errors . Wrap ( err , " " ) } log . Printf ( " " , units . BytesStringBase10 ( atomic . LoadInt64 ( & man . Stats . TotalFileSize ) ) ) if _ , err := snapshot . SaveSnapshot ( ctx , rw , man ) ; err != nil { return errors . Wrap ( err , " " ) } if err := rw . Flush ( ctx ) ; err != nil { return err } return r . Close ( ctx ) }
SnapshotCreate creates a snapshot for the given path.
SnapshotCreate creates a snapshot for the given path .