functional/rpcpb/member.go
func (m *Member) RestoreSnapshot(lg *zap.Logger) (err error) {
	if err = os.RemoveAll(m.EtcdOnSnapshotRestore.DataDir); err != nil {
		return err
	}
	if err = os.RemoveAll(m.EtcdOnSnapshotRestore.WALDir); err != nil {
		return err
	}

	lg.Info(
		"snapshot restore START",
		zap.String("member-name", m.Etcd.Name),
		zap.Strings("member-client-urls", m.Etcd.AdvertiseClientURLs),
		zap.String("snapshot-path", m.SnapshotPath),
	)
	now := time.Now()
	mgr := snapshot.NewV3(lg)
	err = mgr.Restore(snapshot.RestoreConfig{
		SnapshotPath:        m.SnapshotInfo.SnapshotPath,
		Name:                m.EtcdOnSnapshotRestore.Name,
		OutputDataDir:       m.EtcdOnSnapshotRestore.DataDir,
		OutputWALDir:        m.EtcdOnSnapshotRestore.WALDir,
		PeerURLs:            m.EtcdOnSnapshotRestore.AdvertisePeerURLs,
		InitialCluster:      m.EtcdOnSnapshotRestore.InitialCluster,
		InitialClusterToken: m.EtcdOnSnapshotRestore.InitialClusterToken,
		SkipHashCheck:       false,
		// TODO: set SkipHashCheck it true, to recover from existing db file
	})
	took := time.Since(now)
	lg.Info(
		"snapshot restore END",
		zap.String("member-name", m.SnapshotInfo.MemberName),
		zap.Strings("member-client-urls", m.SnapshotInfo.MemberClientURLs),
		zap.String("snapshot-path", m.SnapshotPath),
		zap.String("snapshot-file-size", m.SnapshotInfo.SnapshotFileSize),
		zap.String("snapshot-total-size", m.SnapshotInfo.SnapshotTotalSize),
		zap.Int64("snapshot-total-key", m.SnapshotInfo.SnapshotTotalKey),
		zap.Int64("snapshot-hash", m.SnapshotInfo.SnapshotHash),
		zap.Int64("snapshot-revision", m.SnapshotInfo.SnapshotRevision),
		zap.String("took", took.String()),
		zap.Error(err),
	)
	return err
}
func (m *Member) RestoreSnapshot(lg *zap.Logger) (err error) {
	if err = os.RemoveAll(m.EtcdOnSnapshotRestore.DataDir); err != nil {
		return err
	}
	if err = os.RemoveAll(m.EtcdOnSnapshotRestore.WALDir); err != nil {
		return err
	}

	lg.Info(
		"snapshot restore START",
		zap.String("member-name", m.Etcd.Name),
		zap.Strings("member-client-urls", m.Etcd.AdvertiseClientURLs),
		zap.String("snapshot-path", m.SnapshotPath),
	)
	now := time.Now()
	mgr := snapshot.NewV3(lg)
	err = mgr.Restore(snapshot.RestoreConfig{
		SnapshotPath:        m.SnapshotInfo.SnapshotPath,
		Name:                m.EtcdOnSnapshotRestore.Name,
		OutputDataDir:       m.EtcdOnSnapshotRestore.DataDir,
		OutputWALDir:        m.EtcdOnSnapshotRestore.WALDir,
		PeerURLs:            m.EtcdOnSnapshotRestore.AdvertisePeerURLs,
		InitialCluster:      m.EtcdOnSnapshotRestore.InitialCluster,
		InitialClusterToken: m.EtcdOnSnapshotRestore.InitialClusterToken,
		SkipHashCheck:       false,
		// TODO: set SkipHashCheck it true, to recover from existing db file
	})
	took := time.Since(now)
	lg.Info(
		"snapshot restore END",
		zap.String("member-name", m.SnapshotInfo.MemberName),
		zap.Strings("member-client-urls", m.SnapshotInfo.MemberClientURLs),
		zap.String("snapshot-path", m.SnapshotPath),
		zap.String("snapshot-file-size", m.SnapshotInfo.SnapshotFileSize),
		zap.String("snapshot-total-size", m.SnapshotInfo.SnapshotTotalSize),
		zap.Int64("snapshot-total-key", m.SnapshotInfo.SnapshotTotalKey),
		zap.Int64("snapshot-hash", m.SnapshotInfo.SnapshotHash),
		zap.Int64("snapshot-revision", m.SnapshotInfo.SnapshotRevision),
		zap.String("took", took.String()),
		zap.Error(err),
	)
	return err
}
func ( m * Member ) RestoreSnapshot ( lg * zap . Logger ) ( err error ) { if err = os . RemoveAll ( m . EtcdOnSnapshotRestore . DataDir ) ; err != nil { return err } if err = os . RemoveAll ( m . EtcdOnSnapshotRestore . WALDir ) ; err != nil { return err } lg . Info ( " " , zap . String ( " " , m . Etcd . Name ) , zap . Strings ( " " , m . Etcd . AdvertiseClientURLs ) , zap . String ( " " , m . SnapshotPath ) , ) now := time . Now ( ) mgr := snapshot . NewV3 ( lg ) err = mgr . Restore ( snapshot . RestoreConfig { SnapshotPath : m . SnapshotInfo . SnapshotPath , Name : m . EtcdOnSnapshotRestore . Name , OutputDataDir : m . EtcdOnSnapshotRestore . DataDir , OutputWALDir : m . EtcdOnSnapshotRestore . WALDir , PeerURLs : m . EtcdOnSnapshotRestore . AdvertisePeerURLs , InitialCluster : m . EtcdOnSnapshotRestore . InitialCluster , InitialClusterToken : m . EtcdOnSnapshotRestore . InitialClusterToken , SkipHashCheck : false , // TODO: set SkipHashCheck it true, to recover from existing db file } ) took := time . Since ( now ) lg . Info ( " " , zap . String ( " " , m . SnapshotInfo . MemberName ) , zap . Strings ( " " , m . SnapshotInfo . MemberClientURLs ) , zap . String ( " " , m . SnapshotPath ) , zap . String ( " " , m . SnapshotInfo . SnapshotFileSize ) , zap . String ( " " , m . SnapshotInfo . SnapshotTotalSize ) , zap . Int64 ( " " , m . SnapshotInfo . SnapshotTotalKey ) , zap . Int64 ( " " , m . SnapshotInfo . SnapshotHash ) , zap . Int64 ( " " , m . SnapshotInfo . SnapshotRevision ) , zap . String ( " " , took . String ( ) ) , zap . Error ( err ) , ) return err }
// RestoreSnapshot restores a cluster from a given snapshot file on disk.
// It's meant to requested remotely, so that local member can load the
// snapshot file from local disk.
RestoreSnapshot restores a cluster from a given snapshot file on disk . It s meant to requested remotely so that local member can load the snapshot file from local disk .