task

package
v5.1.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// FlagMergeRegionSizeBytes is the flag name of merge small regions by size
	FlagMergeRegionSizeBytes = "merge-region-size-bytes"
	// FlagMergeRegionKeyCount is the flag name of merge small regions by key count
	FlagMergeRegionKeyCount = "merge-region-key-count"
)

Variables

This section is empty.

Functions

func CheckRestoreDBAndTable

func CheckRestoreDBAndTable(client *restore.Client, cfg *RestoreConfig) error

CheckRestoreDBAndTable is used to check whether the restore dbs or tables have been backup

func DefineBackupFlags

func DefineBackupFlags(flags *pflag.FlagSet)

DefineBackupFlags defines common flags for the backup command.

func DefineCommonFlags

func DefineCommonFlags(flags *pflag.FlagSet)

DefineCommonFlags defines the flags common to all BRIE commands.

func DefineDatabaseFlags

func DefineDatabaseFlags(command *cobra.Command)

DefineDatabaseFlags defines the required --db flag for `db` subcommand.

func DefineFilterFlags

func DefineFilterFlags(command *cobra.Command, defaultFilter []string)

DefineFilterFlags defines the --filter and --case-sensitive flags for `full` subcommand.

func DefineLogRestoreFlags

func DefineLogRestoreFlags(command *cobra.Command)

DefineLogRestoreFlags defines common flags for the backup command.

func DefineRawBackupFlags

func DefineRawBackupFlags(command *cobra.Command)

DefineRawBackupFlags defines common flags for the backup command.

func DefineRawRestoreFlags

func DefineRawRestoreFlags(command *cobra.Command)

DefineRawRestoreFlags defines common flags for the backup command.

func DefineRestoreCommonFlags

func DefineRestoreCommonFlags(flags *pflag.FlagSet)

DefineRestoreCommonFlags defines common flags for the restore command.

func DefineRestoreFlags

func DefineRestoreFlags(flags *pflag.FlagSet)

DefineRestoreFlags defines common flags for the restore tidb command.

func DefineTableFlags

func DefineTableFlags(command *cobra.Command)

DefineTableFlags defines the required --db and --table flags for `table` subcommand.

func GetKeepalive

func GetKeepalive(cfg *Config) keepalive.ClientParameters

GetKeepalive get the keepalive info from the config.

func GetStorage

GetStorage gets the storage backend from the config.

func LogArguments

func LogArguments(cmd *cobra.Command)

LogArguments prints origin command arguments.

func NewMgr

func NewMgr(ctx context.Context,
	g glue.Glue, pds []string,
	tlsConfig TLSConfig,
	keepalive keepalive.ClientParameters,
	checkRequirements bool,
	needDomain bool,
) (*conn.Mgr, error)

NewMgr creates a new mgr at the given PD address.

func ParseTLSTripleFromFlags

func ParseTLSTripleFromFlags(flags *pflag.FlagSet) (ca, cert, key string, err error)

ParseTLSTripleFromFlags parses the (ca, cert, key) triple from flags.

func ReadBackupMeta

func ReadBackupMeta(
	ctx context.Context,
	fileName string,
	cfg *Config,
) (*backuppb.StorageBackend, storage.ExternalStorage, *backuppb.BackupMeta, error)

ReadBackupMeta reads the backupmeta file from the storage.

func RunBackup

func RunBackup(c context.Context, g glue.Glue, cmdName string, cfg *BackupConfig) error

RunBackup starts a backup task inside the current goroutine.

func RunBackupRaw

func RunBackupRaw(c context.Context, g glue.Glue, cmdName string, cfg *RawKvConfig) error

RunBackupRaw starts a backup task inside the current goroutine.

func RunLogRestore

func RunLogRestore(c context.Context, g glue.Glue, cfg *LogRestoreConfig) error

RunLogRestore starts a restore task inside the current goroutine.

func RunRestore

func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConfig) error

RunRestore starts a restore task inside the current goroutine.

func RunRestoreRaw

func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreRawConfig) (err error)

RunRestoreRaw starts a raw kv restore task inside the current goroutine.

Types

type BackupConfig

type BackupConfig struct {
	Config

	TimeAgo          time.Duration `json:"time-ago" toml:"time-ago"`
	BackupTS         uint64        `json:"backup-ts" toml:"backup-ts"`
	LastBackupTS     uint64        `json:"last-backup-ts" toml:"last-backup-ts"`
	GCTTL            int64         `json:"gc-ttl" toml:"gc-ttl"`
	RemoveSchedulers bool          `json:"remove-schedulers" toml:"remove-schedulers"`
	IgnoreStats      bool          `json:"ignore-stats" toml:"ignore-stats"`
	UseBackupMetaV2  bool          `json:"use-backupmeta-v2"`
	CompressionConfig
}

BackupConfig is the configuration specific for backup tasks.

func (*BackupConfig) ParseFromFlags

func (cfg *BackupConfig) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the backup-related flags from the flag set.

type CompressionConfig

type CompressionConfig struct {
	CompressionType  backuppb.CompressionType `json:"compression-type" toml:"compression-type"`
	CompressionLevel int32                    `json:"compression-level" toml:"compression-level"`
}

CompressionConfig is the configuration for sst file compression.

type Config

type Config struct {
	storage.BackendOptions

	Storage             string    `json:"storage" toml:"storage"`
	PD                  []string  `json:"pd" toml:"pd"`
	TLS                 TLSConfig `json:"tls" toml:"tls"`
	RateLimit           uint64    `json:"rate-limit" toml:"rate-limit"`
	ChecksumConcurrency uint      `json:"checksum-concurrency" toml:"checksum-concurrency"`
	Concurrency         uint32    `json:"concurrency" toml:"concurrency"`
	Checksum            bool      `json:"checksum" toml:"checksum"`
	SendCreds           bool      `json:"send-credentials-to-tikv" toml:"send-credentials-to-tikv"`
	// LogProgress is true means the progress bar is printed to the log instead of stdout.
	LogProgress bool `json:"log-progress" toml:"log-progress"`

	// CaseSensitive should not be used.
	//
	// Deprecated: This field is kept only to satisfy the cyclic dependency with TiDB. This field
	// should be removed after TiDB upgrades the BR dependency.
	CaseSensitive bool

	// NoCreds means don't try to load cloud credentials
	NoCreds bool `json:"no-credentials" toml:"no-credentials"`

	CheckRequirements bool `json:"check-requirements" toml:"check-requirements"`
	// EnableOpenTracing is whether to enable opentracing
	EnableOpenTracing bool `json:"enable-opentracing" toml:"enable-opentracing"`
	// SkipCheckPath skips verifying the path
	// deprecated
	SkipCheckPath bool `json:"skip-check-path" toml:"skip-check-path"`
	// Filter should not be used, use TableFilter instead.
	//
	// Deprecated: This field is kept only to satisfy the cyclic dependency with TiDB. This field
	// should be removed after TiDB upgrades the BR dependency.
	Filter filter.MySQLReplicationRules

	TableFilter        filter.Filter `json:"-" toml:"-"`
	SwitchModeInterval time.Duration `json:"switch-mode-interval" toml:"switch-mode-interval"`
	// Schemas is a database name set, to check whether the restore database has been backup
	Schemas map[string]struct{}
	// Tables is a table name set, to check whether the restore table has been backup
	Tables map[string]struct{}

	// GrpcKeepaliveTime is the interval of pinging the server.
	GRPCKeepaliveTime time.Duration `json:"grpc-keepalive-time" toml:"grpc-keepalive-time"`
	// GrpcKeepaliveTimeout is the max time a grpc conn can keep idel before killed.
	GRPCKeepaliveTimeout time.Duration `json:"grpc-keepalive-timeout" toml:"grpc-keepalive-timeout"`
}

Config is the common configuration for all BRIE tasks.

func (*Config) ParseFromFlags

func (cfg *Config) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the config from the flag set.

type LogRestoreConfig

type LogRestoreConfig struct {
	Config

	StartTS uint64
	EndTS   uint64

	BatchFlushKVPairs int
	BatchFlushKVSize  int64
	BatchWriteKVPairs int
}

LogRestoreConfig is the configuration specific for restore tasks.

func (*LogRestoreConfig) ParseFromFlags

func (cfg *LogRestoreConfig) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the restore-related flags from the flag set.

type RawKvConfig

type RawKvConfig struct {
	Config

	StartKey []byte `json:"start-key" toml:"start-key"`
	EndKey   []byte `json:"end-key" toml:"end-key"`
	CF       string `json:"cf" toml:"cf"`
	CompressionConfig
	RemoveSchedulers bool `json:"remove-schedulers" toml:"remove-schedulers"`
}

RawKvConfig is the common config for rawkv backup and restore.

func (*RawKvConfig) ParseBackupConfigFromFlags

func (cfg *RawKvConfig) ParseBackupConfigFromFlags(flags *pflag.FlagSet) error

ParseBackupConfigFromFlags parses the backup-related flags from the flag set.

func (*RawKvConfig) ParseFromFlags

func (cfg *RawKvConfig) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the raw kv backup&restore common flags from the flag set.

type RestoreCommonConfig

type RestoreCommonConfig struct {
	Online bool `json:"online" toml:"online"`

	// MergeSmallRegionSizeBytes is the threshold of merging small regions (Default 96MB, region split size).
	// MergeSmallRegionKeyCount is the threshold of merging smalle regions (Default 960_000, region split key count).
	// See https://github.com/tikv/tikv/blob/v4.0.8/components/raftstore/src/coprocessor/config.rs#L35-L38
	MergeSmallRegionSizeBytes uint64 `json:"merge-region-size-bytes" toml:"merge-region-size-bytes"`
	MergeSmallRegionKeyCount  uint64 `json:"merge-region-key-count" toml:"merge-region-key-count"`
}

RestoreCommonConfig is the common configuration for all BR restore tasks.

func (*RestoreCommonConfig) ParseFromFlags

func (cfg *RestoreCommonConfig) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the config from the flag set.

type RestoreConfig

type RestoreConfig struct {
	Config
	RestoreCommonConfig

	NoSchema bool `json:"no-schema" toml:"no-schema"`
}

RestoreConfig is the configuration specific for restore tasks.

func (*RestoreConfig) ParseFromFlags

func (cfg *RestoreConfig) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the restore-related flags from the flag set.

type RestoreRawConfig

type RestoreRawConfig struct {
	RawKvConfig
	RestoreCommonConfig
}

RestoreRawConfig is the configuration specific for raw kv restore tasks.

func (*RestoreRawConfig) ParseFromFlags

func (cfg *RestoreRawConfig) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the backup-related flags from the flag set.

type TLSConfig

type TLSConfig struct {
	CA   string `json:"ca" toml:"ca"`
	Cert string `json:"cert" toml:"cert"`
	Key  string `json:"key" toml:"key"`
}

TLSConfig is the common configuration for TLS connection.

func (*TLSConfig) IsEnabled

func (tls *TLSConfig) IsEnabled() bool

IsEnabled checks if TLS open or not.

func (*TLSConfig) ParseFromFlags

func (tls *TLSConfig) ParseFromFlags(flags *pflag.FlagSet) error

ParseFromFlags parses the TLS config from the flag set.

func (*TLSConfig) ToTLSConfig

func (tls *TLSConfig) ToTLSConfig() (*tls.Config, error)

ToTLSConfig generate tls.Config.

Jump to

Keyboard shortcuts

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