2024-01-12 13:15:30 +08:00
|
|
|
package dbi
|
2024-01-05 08:55:34 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type DbProgram interface {
|
2024-01-22 03:12:16 +00:00
|
|
|
CheckBinlogEnabled(ctx context.Context) (bool, error)
|
|
|
|
|
CheckBinlogRowFormat(ctx context.Context) (bool, error)
|
|
|
|
|
|
2025-05-20 21:04:47 +08:00
|
|
|
// Backup(ctx context.Context, backupHistory *entity.DbBackupHistory) (*entity.BinlogInfo, error)
|
2024-01-05 22:16:38 +08:00
|
|
|
|
2025-05-20 21:04:47 +08:00
|
|
|
// FetchBinlogs(ctx context.Context, downloadLatestBinlogFile bool, earliestBackupSequence int64, latestBinlogHistory *entity.DbBinlogHistory) ([]*entity.BinlogFile, error)
|
2024-01-05 22:16:38 +08:00
|
|
|
|
2024-01-05 08:55:34 +08:00
|
|
|
ReplayBinlog(ctx context.Context, originalDatabase, targetDatabase string, restoreInfo *RestoreInfo) error
|
2024-01-05 22:16:38 +08:00
|
|
|
|
2024-01-05 08:55:34 +08:00
|
|
|
RestoreBackupHistory(ctx context.Context, dbName string, dbBackupId uint64, dbBackupHistoryUuid string) error
|
2024-01-05 22:16:38 +08:00
|
|
|
|
2024-01-30 13:12:43 +00:00
|
|
|
RemoveBackupHistory(ctx context.Context, dbBackupId uint64, dbBackupHistoryUuid string) error
|
|
|
|
|
|
2024-01-05 08:55:34 +08:00
|
|
|
GetBinlogEventPositionAtOrAfterTime(ctx context.Context, binlogName string, targetTime time.Time) (position int64, parseErr error)
|
2024-02-06 07:16:56 +00:00
|
|
|
|
2025-05-20 21:04:47 +08:00
|
|
|
// PruneBinlog(history *entity.DbBinlogHistory) error
|
2024-01-05 08:55:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type RestoreInfo struct {
|
2025-05-20 21:04:47 +08:00
|
|
|
// BackupHistory *entity.DbBackupHistory
|
|
|
|
|
// BinlogHistories []*entity.DbBinlogHistory
|
|
|
|
|
StartPosition int64
|
|
|
|
|
TargetPosition int64
|
|
|
|
|
TargetTime time.Time
|
2024-01-05 08:55:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ri *RestoreInfo) GetBinlogPaths(binlogDir string) []string {
|
2025-05-20 21:04:47 +08:00
|
|
|
// files := make([]string, 0, len(ri.BinlogHistories))
|
|
|
|
|
// for _, history := range ri.BinlogHistories {
|
|
|
|
|
// files = append(files, filepath.Join(binlogDir, history.FileName))
|
|
|
|
|
// }
|
|
|
|
|
// return files
|
|
|
|
|
return nil
|
2024-01-05 08:55:34 +08:00
|
|
|
}
|