etcd: Index | Files

package snapshot

import ""

Package snapshot implements utilities around etcd snapshot.


Package Files

doc.go util.go v3_snapshot.go

type Manager Uses

type Manager interface {
    // Save fetches snapshot from remote etcd server and saves data
    // to target path. If the context "ctx" is canceled or timed out,
    // snapshot save stream will error out (e.g. context.Canceled,
    // context.DeadlineExceeded). Make sure to specify only one endpoint
    // in client configuration. Snapshot API must be requested to a
    // selected node, and saved snapshot is the point-in-time state of
    // the selected node.
    Save(ctx context.Context, cfg clientv3.Config, dbPath string) error

    // Status returns the snapshot file information.
    Status(dbPath string) (Status, error)

    // Restore restores a new etcd data directory from given snapshot
    // file. It returns an error if specified data directory already
    // exists, to prevent unintended data directory overwrites.
    Restore(cfg RestoreConfig) error

Manager defines snapshot methods.

func NewV3 Uses

func NewV3(lg *zap.Logger) Manager

NewV3 returns a new snapshot Manager for v3.x snapshot.

type RestoreConfig Uses

type RestoreConfig struct {
    // SnapshotPath is the path of snapshot file to restore from.
    SnapshotPath string

    // Name is the human-readable name of this member.
    Name string

    // OutputDataDir is the target data directory to save restored data.
    // OutputDataDir should not conflict with existing etcd data directory.
    // If OutputDataDir already exists, it will return an error to prevent
    // unintended data directory overwrites.
    // If empty, defaults to "[Name].etcd" if not given.
    OutputDataDir string
    // OutputWALDir is the target WAL data directory.
    // If empty, defaults to "[OutputDataDir]/member/wal" if not given.
    OutputWALDir string

    // PeerURLs is a list of member's peer URLs to advertise to the rest of the cluster.
    PeerURLs []string

    // InitialCluster is the initial cluster configuration for restore bootstrap.
    InitialCluster string
    // InitialClusterToken is the initial cluster token for etcd cluster during restore bootstrap.
    InitialClusterToken string

    // SkipHashCheck is "true" to ignore snapshot integrity hash value
    // (required if copied from data directory).
    SkipHashCheck bool

RestoreConfig configures snapshot restore operation.

type Status Uses

type Status struct {
    Hash      uint32 `json:"hash"`
    Revision  int64  `json:"revision"`
    TotalKey  int    `json:"totalKey"`
    TotalSize int64  `json:"totalSize"`

Status is the snapshot file status.

Package snapshot imports 33 packages (graph) and is imported by 9 packages. Updated 2020-06-02. Refresh now. Tools for package owners.