Documentation ¶
Index ¶
- Constants
- Variables
- func IsInformationSchema(database string) bool
- func NewBackupName() string
- func ShallSkipDatabase(cfg *config.Config, targetDB, tablePattern string) bool
- type Backuper
- func (b *Backuper) AddTableToLocalBackup(ctx context.Context, backupName string, ...) (map[string][]metadata.Part, map[string]int64, map[string]int64, error)
- func (b *Backuper) Clean(ctx context.Context) error
- func (b *Backuper) CleanRemoteBroken(commandId int) error
- func (b *Backuper) CreateBackup(backupName, diffFromRemote, tablePattern string, partitions []string, ...) error
- func (b *Backuper) CreateToRemote(backupName string, deleteSource bool, ...) error
- func (b *Backuper) Delete(backupType, backupName string, commandId int) error
- func (b *Backuper) Download(backupName string, tablePattern string, partitions []string, ...) error
- func (b *Backuper) GetLocalBackups(ctx context.Context, disks []clickhouse.Disk) ([]LocalBackup, []clickhouse.Disk, error)
- func (b *Backuper) GetRemoteBackups(ctx context.Context, parseMetadata bool) ([]storage.Backup, error)
- func (b *Backuper) GetTables(ctx context.Context, tablePattern string) ([]clickhouse.Table, error)
- func (b *Backuper) GetTablesRemote(ctx context.Context, backupName string, tablePattern string) ([]clickhouse.Table, error)
- func (b *Backuper) List(what, format string) error
- func (b *Backuper) NewBackupWatchName(ctx context.Context, backupType string) (string, error)
- func (b *Backuper) PrintAllBackups(ctx context.Context, format string) error
- func (b *Backuper) PrintLocalBackups(ctx context.Context, format string) error
- func (b *Backuper) PrintRemoteBackups(ctx context.Context, format string) error
- func (b *Backuper) PrintTables(printAll bool, tablePattern, remoteBackup string) error
- func (b *Backuper) ReadBackupMetadataLocal(ctx context.Context, backupName string) (*metadata.BackupMetadata, error)
- func (b *Backuper) ReadBackupMetadataRemote(ctx context.Context, backupName string) (*metadata.BackupMetadata, error)
- func (b *Backuper) RemoveBackupLocal(ctx context.Context, backupName string, disks []clickhouse.Disk) error
- func (b *Backuper) RemoveBackupRemote(ctx context.Context, backupName string) error
- func (b *Backuper) RemoveOldBackupsLocal(ctx context.Context, keepLastBackup bool, disks []clickhouse.Disk) error
- func (b *Backuper) RemoveOldBackupsRemote(ctx context.Context) error
- func (b *Backuper) Restore(backupName, tablePattern string, ...) error
- func (b *Backuper) RestoreData(ctx context.Context, backupName string, backupMetadata metadata.BackupMetadata, ...) error
- func (b *Backuper) RestoreFromRemote(backupName, tablePattern string, ...) error
- func (b *Backuper) RestoreSchema(ctx context.Context, backupName string, backupMetadata metadata.BackupMetadata, ...) error
- func (b *Backuper) Upload(backupName string, deleteSource bool, ...) error
- func (b *Backuper) ValidateWatchParams(watchInterval, fullInterval, watchBackupNameTemplate string) error
- func (b *Backuper) Watch(watchInterval, fullInterval, watchBackupNameTemplate, tablePattern string, ...) error
- type BackuperOpt
- type ListOfTables
- type LocalBackup
Constants ¶
const ( // TimeFormatForBackup - default backup name format TimeFormatForBackup = "2006-01-02T15-04-05" MetaFileName = "metadata.json" )
const DirectoryFormat = "directory"
Variables ¶
var CreateDatabaseRE = regexp.MustCompile(`(?m)^CREATE DATABASE (\s*)(\S+)(\s*)`)
var (
ErrBackupIsAlreadyExists = errors.New("backup is already exists")
)
var ( // ErrUnknownClickhouseDataPath - ErrUnknownClickhouseDataPath = errors.New("clickhouse data path is unknown, you can set data_path in config file") )
var UUIDWithMergeTreeRE = regexp.MustCompile(`^(.+)(UUID)(\s+)'([^']+)'(.+)({uuid})(.*)`)
Functions ¶
func IsInformationSchema ¶
Types ¶
type Backuper ¶
type Backuper struct { DiskToPathMap map[string]string DefaultDataPath string EmbeddedBackupDataPath string // contains filtered or unexported fields }
func NewBackuper ¶
func NewBackuper(cfg *config.Config, opts ...BackuperOpt) *Backuper
func (*Backuper) AddTableToLocalBackup ¶ added in v2.5.0
func (b *Backuper) AddTableToLocalBackup(ctx context.Context, backupName string, tablesDiffFromRemote map[metadata.TableTitle]metadata.TableMetadata, shadowBackupUUID string, diskList []clickhouse.Disk, table *clickhouse.Table, partitionsIdsMap common.EmptyMap, version int) (map[string][]metadata.Part, map[string]int64, map[string]int64, error)
func (*Backuper) CleanRemoteBroken ¶
func (*Backuper) CreateBackup ¶
func (b *Backuper) CreateBackup(backupName, diffFromRemote, tablePattern string, partitions []string, schemaOnly, createRBAC, rbacOnly, createConfigs, configsOnly, skipCheckPartsColumns bool, backupVersion string, commandId int) error
CreateBackup - create new backup of all tables matched by tablePattern If backupName is empty string will use default backup name
func (*Backuper) CreateToRemote ¶
func (*Backuper) GetLocalBackups ¶
func (b *Backuper) GetLocalBackups(ctx context.Context, disks []clickhouse.Disk) ([]LocalBackup, []clickhouse.Disk, error)
GetLocalBackups - return slice of all backups stored locally
func (*Backuper) GetRemoteBackups ¶
func (b *Backuper) GetRemoteBackups(ctx context.Context, parseMetadata bool) ([]storage.Backup, error)
GetRemoteBackups - get all backups stored on remote storage
func (*Backuper) GetTables ¶
GetTables - get all tables for use by CreateBackup, PrintTables, and API
func (*Backuper) GetTablesRemote ¶ added in v2.5.0
func (*Backuper) NewBackupWatchName ¶
func (*Backuper) PrintAllBackups ¶
func (*Backuper) PrintLocalBackups ¶
PrintLocalBackups - print all backups stored locally
func (*Backuper) PrintRemoteBackups ¶
PrintRemoteBackups - print all backups stored on remote storage
func (*Backuper) PrintTables ¶
PrintTables - print all tables suitable for backup
func (*Backuper) ReadBackupMetadataLocal ¶
func (*Backuper) ReadBackupMetadataRemote ¶
func (*Backuper) RemoveBackupLocal ¶
func (*Backuper) RemoveBackupRemote ¶
func (*Backuper) RemoveOldBackupsLocal ¶
func (*Backuper) RemoveOldBackupsRemote ¶ added in v2.4.28
func (*Backuper) Restore ¶
func (b *Backuper) Restore(backupName, tablePattern string, databaseMapping, tableMapping, partitions []string, schemaOnly, dataOnly, dropExists, ignoreDependencies, restoreRBAC, rbacOnly, restoreConfigs, configsOnly bool, backupVersion string, commandId int) error
Restore - restore tables matched by tablePattern from backupName
func (*Backuper) RestoreData ¶
func (b *Backuper) RestoreData(ctx context.Context, backupName string, backupMetadata metadata.BackupMetadata, dataOnly bool, metadataPath, tablePattern string, partitions []string, disks []clickhouse.Disk, version int) error
RestoreData - restore data for tables matched by tablePattern from backupName
func (*Backuper) RestoreFromRemote ¶
func (*Backuper) RestoreSchema ¶
func (b *Backuper) RestoreSchema(ctx context.Context, backupName string, backupMetadata metadata.BackupMetadata, disks []clickhouse.Disk, tablesForRestore ListOfTables, ignoreDependencies bool, version int) error
RestoreSchema - restore schemas matched by tablePattern from backupName
func (*Backuper) ValidateWatchParams ¶
func (*Backuper) Watch ¶
func (b *Backuper) Watch(watchInterval, fullInterval, watchBackupNameTemplate, tablePattern string, partitions []string, schemaOnly, backupRBAC, backupConfigs, skipCheckPartsColumns bool, version string, commandId int, metrics metrics.APIMetricsInterface, cliCtx *cli.Context) error
Watch - run create_remote full + delete local full, even when upload failed
- if success save backup type full, next will increment, until reach full interval
- if fail save previous backup type empty, next try will also full
- each watch-interval, run create_remote increment --diff-from=prev-name + delete local increment, even when upload failed
- save previous backup type incremental, next try will also incremental, until reach full interval
type BackuperOpt ¶
type BackuperOpt func(*Backuper)
func WithBackupSharder ¶
func WithBackupSharder(s backupSharder) BackuperOpt
func WithVersioner ¶
func WithVersioner(v versioner) BackuperOpt
type ListOfTables ¶
type ListOfTables []metadata.TableMetadata
func (ListOfTables) Sort ¶
func (lt ListOfTables) Sort(dropTable bool)
Sort - sorting ListOfTables slice orderly by engine priority
type LocalBackup ¶
type LocalBackup struct { metadata.BackupMetadata Broken string }
func GetBackupsToDeleteLocal ¶ added in v2.4.28
func GetBackupsToDeleteLocal(backups []LocalBackup, keep int) []LocalBackup