Documentation ¶
Index ¶
- Constants
- Variables
- func CalcVolSnapBackupSize(ctx context.Context, provider v1alpha1.StorageProvider, level string) (fullBackupSize int64, incrementalBackupSize int64, err error)
- func ConstructBRGlobalOptionsForBackup(backup *v1alpha1.Backup) ([]string, error)
- func ConstructBRGlobalOptionsForRestore(restore *v1alpha1.Restore) ([]string, error)
- func ConstructDumplingOptionsForBackup(backup *v1alpha1.Backup) []string
- func ConstructRcloneArgs(conf string, opts []string, command, source, dest string, verboseLog bool) []string
- func EnsureDirectoryExist(dirName string) error
- func GetBRArchiveSize(meta *kvbackup.BackupMeta) uint64
- func GetBRMetaData(ctx context.Context, provider v1alpha1.StorageProvider) (*kvbackup.BackupMeta, error)
- func GetCommitTsFromBRMetaData(ctx context.Context, provider v1alpha1.StorageProvider) (uint64, error)
- func GetCommitTsFromMetadata(backupPath string) (string, error)
- func GetContextForTerminationSignals(op string) (context.Context, context.CancelFunc)
- func GetOptionValueFromEnv(option, envPrefix string) string
- func GetOptions(provider v1alpha1.StorageProvider) []string
- func GetSliceExcludeOneString(strs []string, str string) []string
- func GetStoragePath(backup *v1alpha1.Backup) (string, error)
- func GracefullyShutDownSubProcess(ctx context.Context, cmd *exec.Cmd)
- func IsDirExist(path string) bool
- func IsE2EExtendBackupTime() bool
- func IsE2EExtendBackupTimeAndPanic() bool
- func IsFileExist(file string) bool
- func NewCRCli(kubeconfig string) (versioned.Interface, error)
- func NewEventRecorder(kubeCli kubernetes.Interface, source string) record.EventRecorder
- func NewKubeAndCRCli(kubeconfig string) (kubernetes.Interface, versioned.Interface, error)
- func NewKubeCli(kubeconfig string) (kubernetes.Interface, error)
- func NormalizeBucketURI(bucket string) string
- func ParseRestoreProgress(line string) (step, progress string)
- func ReadAllStdErrToChannel(stdErr io.Reader, errMsgCh chan []byte)
- func RetriableOnAnyError(err error) bool
- func RetryOnError(ctx context.Context, attempts int, sleep time.Duration, ...) error
- func Suffix(version string) string
- func ValidCmdFlags(cmdPath string, flagSet *pflag.FlagSet)
- type GenericOptions
- func (bo *GenericOptions) GetDSN(enabledTLSClient bool) (string, error)
- func (bo *GenericOptions) GetTikvGCLifeTime(ctx context.Context, db *sql.DB) (string, error)
- func (bo *GenericOptions) SetTikvGCLifeTime(ctx context.Context, db *sql.DB, gcTime string) error
- func (bo *GenericOptions) String() string
Constants ¶
const ( // DescribeSnapMaxReturnResult can be between 5 and 1,000; if MaxResults is given a value larger than 1,000, only 1,000 results are returned. DescribeSnapMaxReturnResult = 1000 // ListSnapMaxReturnResult can be between 100 and 10,000, and charge ~0.6$/1 million request ListSnapMaxReturnResult = 10000 // EbsApiConcurrency can be between 1 and 50 due to aws service quota EbsApiConcurrency = 40 CalculateFullSize = "full" CalculateIncremental = "incremental" CalculateAll = "all" )
Variables ¶
var (
// DefaultVersion is the default tikv and br version
DefaultVersion = "4.0"
)
Functions ¶
func CalcVolSnapBackupSize ¶ added in v1.4.4
func CalcVolSnapBackupSize(ctx context.Context, provider v1alpha1.StorageProvider, level string) (fullBackupSize int64, incrementalBackupSize int64, err error)
CalcVolSnapBackupSize get snapshots from backup meta and then calc the backup size of snapshots.
func ConstructBRGlobalOptionsForBackup ¶
ConstructBRGlobalOptionsForBackup constructs BR global options for backup and also return the remote path.
func ConstructBRGlobalOptionsForRestore ¶
ConstructBRGlobalOptionsForRestore constructs BR global options for restore.
func ConstructDumplingOptionsForBackup ¶ added in v1.1.3
ConstructDumplingOptionsForBackup constructs dumpling options for backup
func ConstructRcloneArgs ¶ added in v1.1.8
func ConstructRcloneArgs(conf string, opts []string, command, source, dest string, verboseLog bool) []string
ConstructRcloneArgs constructs the rclone args
func EnsureDirectoryExist ¶
EnsureDirectoryExist create directory if does not exist
func GetBRArchiveSize ¶ added in v1.1.7
func GetBRArchiveSize(meta *kvbackup.BackupMeta) uint64
GetBRArchiveSize returns the total size of the backup archive.
func GetBRMetaData ¶ added in v1.1.7
func GetBRMetaData(ctx context.Context, provider v1alpha1.StorageProvider) (*kvbackup.BackupMeta, error)
GetBRMetaData get backup metadata from cloud storage
func GetCommitTsFromBRMetaData ¶ added in v1.1.3
func GetCommitTsFromBRMetaData(ctx context.Context, provider v1alpha1.StorageProvider) (uint64, error)
GetCommitTsFromBRMetaData get backup position from `EndVersion` in BR backup meta
func GetCommitTsFromMetadata ¶ added in v1.1.3
GetCommitTsFromMetadata get commitTs from mydumper's metadata file
metadata file format is as follows:
Started dump at: 2019-06-13 10:00:04 SHOW MASTER STATUS: Log: tidb-binlog Pos: 409054741514944513 GTID: Finished dump at: 2019-06-13 10:00:04
func GetContextForTerminationSignals ¶ added in v1.1.10
func GetContextForTerminationSignals(op string) (context.Context, context.CancelFunc)
GetContextForTerminationSignals get a context for some termination signals, and the context will become done after any of these signals triggered.
func GetOptionValueFromEnv ¶
GetOptionValueFromEnv get option's value from environment variable. If unset, return empty string.
func GetOptions ¶
func GetOptions(provider v1alpha1.StorageProvider) []string
GetOptions gets the rclone options
func GetSliceExcludeOneString ¶ added in v1.4.0
GetSliceExcludeString get a slice of strings that excludes the specified substring
func GetStoragePath ¶ added in v1.1.8
GetStoragePath generate the path of a specific storage
func GracefullyShutDownSubProcess ¶ added in v1.5.1
GracefullyShutDownSubProcess just send SIGTERM to the process of cmd when context done the caller should wait the process of cmd to shut down
func IsDirExist ¶
IsDirExist return true if path exist and is a dir, other cases return false
func IsE2EExtendBackupTime ¶ added in v1.4.4
func IsE2EExtendBackupTime() bool
func IsE2EExtendBackupTimeAndPanic ¶ added in v1.4.4
func IsE2EExtendBackupTimeAndPanic() bool
func IsFileExist ¶
IsFileExist return true if file exist and is a regular file, other cases return false
func NewEventRecorder ¶
func NewEventRecorder(kubeCli kubernetes.Interface, source string) record.EventRecorder
NewEventRecorder return the specify source's recoder
func NewKubeAndCRCli ¶
NewKubeAndCRCli create both kube cli and CR cli
func NewKubeCli ¶
func NewKubeCli(kubeconfig string) (kubernetes.Interface, error)
NewKubeCli create a kubeCli Interface
func NormalizeBucketURI ¶
NormalizeBucketURI normal bucket URL for rclone, e.g. s3://bucket -> s3:bucket
func ParseRestoreProgress ¶ added in v1.4.0
ParseRestoreProgress parse restore progress and return restore step and progress
func ReadAllStdErrToChannel ¶ added in v1.5.1
ReadAllStdErrToChannel read the stdErr and send the output to channel
func RetriableOnAnyError ¶ added in v1.3.7
func RetryOnError ¶ added in v1.3.7
func RetryOnError(ctx context.Context, attempts int, sleep time.Duration, retriable func(error) bool, fn func() error) error
RetryOnError allows the caller to retry fn in case the error returned by fn. sleep define the interval between two retries.
func ValidCmdFlags ¶
ValidCmdFlags verify that all flags are set
Types ¶
type GenericOptions ¶
type GenericOptions struct { Namespace string // ResourceName can be the name of a backup or restore resource ResourceName string TLSClient bool TLSCluster bool SkipClientCA bool Host string Port int32 Password string User string TiKVVersion string Mode string SubCommand string CommitTS string TruncateUntil string PitrRestoredTs string Initialize bool }
GenericOptions contains the generic input arguments to the backup/restore command
func (*GenericOptions) GetDSN ¶
func (bo *GenericOptions) GetDSN(enabledTLSClient bool) (string, error)
func (*GenericOptions) GetTikvGCLifeTime ¶
func (*GenericOptions) SetTikvGCLifeTime ¶
func (*GenericOptions) String ¶
func (bo *GenericOptions) String() string