Documentation ¶
Index ¶
- Constants
- func BuildBackupMeta(req *backuppb.BackupRequest, files []*backuppb.File, ...) (backupMeta backuppb.BackupMeta, err error)
- func BuildTableRanges(tbl *model.TableInfo) ([]kv.KeyRange, error)
- func ChecksumMatches(backupMeta *backuppb.BackupMeta, local []Checksum) error
- func GetBackupDDLJobs(store kv.Storage, lastBackupTS, backupTS uint64) ([]*model.Job, error)
- func OnBackupResponse(storeID uint64, bo *tikv.Backoffer, backupTS uint64, ...) (*backuppb.BackupResponse, int, error)
- func SendBackup(ctx context.Context, storeID uint64, client backuppb.BackupClient, ...) error
- type Checksum
- type Client
- func (bc *Client) BackupRange(ctx context.Context, startKey, endKey []byte, req backuppb.BackupRequest, ...) (files []*backuppb.File, err error)
- func (bc *Client) BackupRanges(ctx context.Context, ranges []rtree.Range, req backuppb.BackupRequest, ...) ([]*backuppb.File, error)
- func (bc *Client) GetClusterID() uint64
- func (bc *Client) GetGCTTL() int64
- func (bc *Client) GetTS(ctx context.Context, duration time.Duration, ts uint64) (uint64, error)
- func (bc *Client) SaveBackupMeta(ctx context.Context, backupMeta *backuppb.BackupMeta) error
- func (bc *Client) SetGCTTL(ttl int64)
- func (bc *Client) SetLockFile(ctx context.Context) error
- func (bc *Client) SetStorage(ctx context.Context, backend *backuppb.StorageBackend, ...) error
- type ClientMgr
- type ProgressUnit
- type Schemas
Constants ¶
const ( // DefaultSchemaConcurrency is the default number of the concurrent // backup schema tasks. DefaultSchemaConcurrency = 64 )
Variables ¶
This section is empty.
Functions ¶
func BuildBackupMeta ¶
func BuildBackupMeta( req *backuppb.BackupRequest, files []*backuppb.File, rawRanges []*backuppb.RawRange, ddlJobs []*model.Job, clusterVersion string, brVersion string, ) (backupMeta backuppb.BackupMeta, err error)
BuildBackupMeta constructs the backup meta file from its components.
func BuildTableRanges ¶
BuildTableRanges returns the key ranges encompassing the entire table, and its partitions if exists.
func ChecksumMatches ¶
func ChecksumMatches(backupMeta *backuppb.BackupMeta, local []Checksum) error
ChecksumMatches tests whether the "local" checksum matches the checksum from TiKV.
func GetBackupDDLJobs ¶
GetBackupDDLJobs returns the ddl jobs are done in (lastBackupTS, backupTS].
func OnBackupResponse ¶
func OnBackupResponse( storeID uint64, bo *tikv.Backoffer, backupTS uint64, lockResolver *tikv.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 Checksum ¶
Checksum is the checksum of some backup files calculated by CollectChecksums.
func CollectChecksums ¶
func CollectChecksums(backupMeta *backuppb.BackupMeta) ([]Checksum, error)
CollectChecksums check data integrity by xor all(sst_checksum) per table it returns the checksum of all local files.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client instructs TiKV how to do a backup.
func NewBackupClient ¶
NewBackupClient returns a new backup client.
func (*Client) BackupRange ¶
func (bc *Client) BackupRange( ctx context.Context, startKey, endKey []byte, req backuppb.BackupRequest, progressCallBack func(ProgressUnit), ) (files []*backuppb.File, 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, progressCallBack func(ProgressUnit), ) ([]*backuppb.File, error)
BackupRanges make a backup of the given key ranges.
func (*Client) GetClusterID ¶
GetClusterID returns the cluster ID of the tidb cluster to backup.
func (*Client) SaveBackupMeta ¶
SaveBackupMeta saves the current backup meta at the given path.
func (*Client) SetLockFile ¶
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.
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() *tikv.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.
type Schemas ¶
type Schemas struct {
// contains filtered or unexported fields
}
Schemas is task for backuping schemas.
func BuildBackupRangeAndSchema ¶
func BuildBackupRangeAndSchema( storage kv.Storage, tableFilter filter.Filter, backupTS uint64, ) ([]rtree.Range, *Schemas, error)
BuildBackupRangeAndSchema gets KV range and schema of tables. KV ranges are separated by Table IDs. Also, KV ranges are separated by Index IDs in the same table.
func (*Schemas) BackupSchemas ¶
func (ss *Schemas) BackupSchemas( ctx context.Context, store kv.Storage, statsHandle *handle.Handle, backupTS uint64, concurrency uint, copConcurrency uint, skipChecksum bool, updateCh glue.Progress, ) ([]*backuppb.Schema, error)
BackupSchemas backups table info, including checksum and stats.