backup

package
v0.0.0-...-1b33b2a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0, Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBackupStorageIsLocked

func CheckBackupStorageIsLocked(ctx context.Context, s storage.ExternalStorage) error

CheckBackupStorageIsLocked checks whether backups is locked. which means we found other backup progress already write some data files into the same backup directory or cloud prefix.

func OnBackupResponse

func OnBackupResponse(
	storeID uint64,
	bo *tikv.Backoffer,
	backupTS uint64,
	lockResolver *txnlock.LockResolver,
	resp *backuppb.BackupResponse,
) (*backuppb.BackupResponse, int, error)

OnBackupResponse checks the backup resp, decides whether to retry and generate the error.

func SendBackup

func SendBackup(
	ctx context.Context,

	storeID uint64,
	client backuppb.BackupClient,
	req backuppb.BackupRequest,
	respFn func(*backuppb.BackupResponse) error,
	resetFn func() (backuppb.BackupClient, error),
) error

SendBackup send backup request to the given store. Stop receiving response if respFn returns error.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client instructs TiKV how to do a backup.

func NewBackupClient

func NewBackupClient(ctx context.Context, mgr ClientMgr, config *tls.Config) (*Client, error)

NewBackupClient returns a new backup client.

func (*Client) BackupRange

func (bc *Client) BackupRange(
	ctx context.Context,
	startKey, endKey []byte,
	req backuppb.BackupRequest,
	metaWriter *metautil.MetaWriter,
	progressCallBack func(ProgressUnit),
) (err error)

BackupRange make a backup of the given key range. Returns an array of files backed up.

func (*Client) BackupRanges

func (bc *Client) BackupRanges(
	ctx context.Context,
	ranges []rtree.Range,
	req backuppb.BackupRequest,
	concurrency uint,
	metaWriter *metautil.MetaWriter,
	progressCallBack func(ProgressUnit),
) error

BackupRanges make a backup of the given key ranges.

func (*Client) GetClusterID

func (bc *Client) GetClusterID() uint64

GetClusterID returns the cluster ID of the tidb cluster to backup.

func (*Client) GetCurAPIVersion

func (bc *Client) GetCurAPIVersion() kvrpcpb.APIVersion

func (*Client) GetGCTTL

func (bc *Client) GetGCTTL() time.Duration

GetGCTTL get gcTTL for this backup.

func (*Client) GetStorage

func (bc *Client) GetStorage() storage.ExternalStorage

GetStorage gets storage for this backup.

func (*Client) GetTS

func (bc *Client) GetTS(ctx context.Context, duration time.Duration, ts uint64) (uint64, error)

GetTS returns the latest timestamp.

func (*Client) SetGCTTL

func (bc *Client) SetGCTTL(ttl time.Duration)

SetGCTTL set gcTTL for client.

func (*Client) SetLockFile

func (bc *Client) SetLockFile(ctx context.Context) error

SetLockFile set write lock file.

func (*Client) SetStorage

func (bc *Client) SetStorage(ctx context.Context, backend *backuppb.StorageBackend, opts *storage.ExternalStorageOptions) error

SetStorage set ExternalStorage for client.

func (*Client) UpdateBRGCSafePoint

func (bc *Client) UpdateBRGCSafePoint(ctx context.Context, safeInterval time.Duration) (uint64, error)

type ClientMgr

type ClientMgr interface {
	GetBackupClient(ctx context.Context, storeID uint64) (backuppb.BackupClient, error)
	ResetBackupClient(ctx context.Context, storeID uint64) (backuppb.BackupClient, error)
	GetPDClient() pd.Client
	GetLockResolver() *txnlock.LockResolver
	Close()
}

ClientMgr manages connections needed by backup.

type ProgressUnit

type ProgressUnit string

ProgressUnit represents the unit of progress.

const (

	// RangeUnit represents the progress updated counter when a range finished.
	RangeUnit ProgressUnit = "range"
	// RegionUnit represents the progress updated counter when a region finished.
	RegionUnit ProgressUnit = "region"
)

Maximum total sleep time(in ms) for kv/cop commands.

Jump to

Keyboard shortcuts

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