etcd

package
v0.0.0-...-5067e2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2021 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// FileVersion is the version of the backup file we produce.
	FileVersion = "1"

	// DefaultMinRestoreTTL is the minimum TTL to restore to the etcd cluster
	// https://github.com/coreos/etcd/blob/6dcd020d7da9730caf261a46378dce363c296519/lease/lessor.go#L34
	DefaultMinRestoreTTL = 5 * time.Second
)

Variables

This section is empty.

Functions

func Backup

func Backup(ctx context.Context, conf BackupConfig) error

func OfflineRestore

func OfflineRestore(ctx context.Context, conf RestoreConfig, dir string) error

OfflineRestore restores the etcdv3 database to an offline etcd nodes snapshot DB.

func Restore

func Restore(ctx context.Context, conf RestoreConfig) error

Restore restores a backup to an etcd database using the etcd API (does not preserve revision or index numbers)

Types

type BackupConfig

type BackupConfig struct {
	EtcdConfig etcdconf.Config
	Prefix     []string
	Writer     io.Writer
	Log        log.FieldLogger
}

BackupConfig are the settings to use for running a backup of the etcd database

func (*BackupConfig) CheckAndSetDefaults

func (b *BackupConfig) CheckAndSetDefaults() error

type KeyValue

type KeyValue struct {
	// key is the key in bytes. An empty key is not allowed.
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// create_revision is the revision of last creation on this key.
	CreateRevision int64 `protobuf:"varint,2,opt,name=create_revision,json=createRevision,proto3" json:"create_revision,omitempty"`
	// mod_revision is the revision of last modification on this key.
	ModRevision int64 `protobuf:"varint,3,opt,name=mod_revision,json=modRevision,proto3" json:"mod_revision,omitempty"`
	// version is the version of the key. A deletion resets
	// the version to zero and any modification of the key
	// increases its version.
	Version int64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"`
	// value is the value held by the key, in bytes.
	Value []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"`
	// lease is the ID of the lease that attached to key.
	// When the attached lease expires, the key will be deleted.
	// If lease is 0, then no lease is attached to the key.
	Lease int64 `protobuf:"varint,6,opt,name=lease,proto3" json:"lease,omitempty"`
	// TTL (not from etcd datastructure)
	// This is the TTL of the key, which we look up during the backup, because etcd3 stores these separatly from the key
	TTL int64 `json:"ttl,omitempty"`
}

KeyValue is a clone of the internal KeyValue from etcd which isn't exported

type RestoreConfig

type RestoreConfig struct {
	EtcdConfig    etcdconf.Config
	Prefix        []string
	MigratePrefix []string
	File          string
	MinRestoreTTL time.Duration
	Log           log.FieldLogger
	SkipV3        bool
}

BackupConfig are the settings to use for running a backup of the etcd database

func (*RestoreConfig) CheckAndSetDefaults

func (b *RestoreConfig) CheckAndSetDefaults() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL