backup

package
v2.5.9 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TimeFormatForBackup - default backup name format
	TimeFormatForBackup = "2006-01-02T15-04-05"
	MetaFileName        = "metadata.json"
)
View Source
const DirectoryFormat = "directory"

Variables

View Source
var CreateDatabaseRE = regexp.MustCompile(`(?m)^CREATE DATABASE (\s*)(\S+)(\s*)`)
View Source
var (
	ErrBackupIsAlreadyExists = errors.New("backup is already exists")
)
View Source
var (
	// ErrUnknownClickhouseDataPath -
	ErrUnknownClickhouseDataPath = errors.New("clickhouse data path is unknown, you can set data_path in config file")
)
View Source
var UUIDWithMergeTreeRE = regexp.MustCompile(`^(.+)(UUID)(\s+)'([^']+)'(.+)({uuid})(.*)`)

Functions

func IsInformationSchema

func IsInformationSchema(database string) bool

func NewBackupName

func NewBackupName() string

NewBackupName - return default backup name

func ShallSkipDatabase

func ShallSkipDatabase(cfg *config.Config, targetDB, tablePattern string) bool

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) (map[string][]metadata.Part, map[string]int64, error)

func (*Backuper) Clean

func (b *Backuper) Clean(ctx context.Context) error

Clean - removed all data in shadow folder

func (*Backuper) CleanRemoteBroken

func (b *Backuper) CleanRemoteBroken(commandId int) error

func (*Backuper) CreateBackup

func (b *Backuper) CreateBackup(backupName, diffFromRemote, tablePattern string, partitions []string, schemaOnly, createRBAC, rbacOnly, createConfigs, configsOnly, skipCheckPartsColumns bool, version 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 (b *Backuper) CreateToRemote(backupName string, deleteSource bool, diffFrom, diffFromRemote, tablePattern string, partitions []string, schemaOnly, backupRBAC, rbacOnly, backupConfigs, configsOnly, skipCheckPartsColumns, resume bool, version string, commandId int) error

func (*Backuper) Delete

func (b *Backuper) Delete(backupType, backupName string, commandId int) error

Delete - remove local or remote backup

func (*Backuper) Download

func (b *Backuper) Download(backupName string, tablePattern string, partitions []string, schemaOnly, resume bool, backupVersion string, commandId int) error

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

func (b *Backuper) GetTables(ctx context.Context, tablePattern string) ([]clickhouse.Table, error)

GetTables - get all tables for use by CreateBackup, PrintTables, and API

func (*Backuper) GetTablesRemote added in v2.5.0

func (b *Backuper) GetTablesRemote(ctx context.Context, backupName string, tablePattern string) ([]clickhouse.Table, error)

func (*Backuper) List

func (b *Backuper) List(what, format string) error

List - list backups to stdout from command line

func (*Backuper) NewBackupWatchName

func (b *Backuper) NewBackupWatchName(ctx context.Context, backupType string) (string, error)

func (*Backuper) PrintAllBackups

func (b *Backuper) PrintAllBackups(ctx context.Context, format string) error

func (*Backuper) PrintLocalBackups

func (b *Backuper) PrintLocalBackups(ctx context.Context, format string) error

PrintLocalBackups - print all backups stored locally

func (*Backuper) PrintRemoteBackups

func (b *Backuper) PrintRemoteBackups(ctx context.Context, format string) error

PrintRemoteBackups - print all backups stored on remote storage

func (*Backuper) PrintTables

func (b *Backuper) PrintTables(printAll bool, tablePattern, remoteBackup string) error

PrintTables - print all tables suitable for backup

func (*Backuper) ReadBackupMetadataLocal

func (b *Backuper) ReadBackupMetadataLocal(ctx context.Context, backupName string) (*metadata.BackupMetadata, error)

func (*Backuper) ReadBackupMetadataRemote

func (b *Backuper) ReadBackupMetadataRemote(ctx context.Context, backupName string) (*metadata.BackupMetadata, error)

func (*Backuper) RemoveBackupLocal

func (b *Backuper) RemoveBackupLocal(ctx context.Context, backupName string, disks []clickhouse.Disk) error

func (*Backuper) RemoveBackupRemote

func (b *Backuper) RemoveBackupRemote(ctx context.Context, backupName string) error

func (*Backuper) RemoveOldBackupsLocal

func (b *Backuper) RemoveOldBackupsLocal(ctx context.Context, keepLastBackup bool, disks []clickhouse.Disk) error

func (*Backuper) RemoveOldBackupsRemote added in v2.4.28

func (b *Backuper) RemoveOldBackupsRemote(ctx context.Context) error

func (*Backuper) Restore

func (b *Backuper) Restore(backupName, tablePattern string, databaseMapping, 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) error

RestoreData - restore data for tables matched by tablePattern from backupName

func (*Backuper) RestoreFromRemote

func (b *Backuper) RestoreFromRemote(backupName, tablePattern string, databaseMapping, partitions []string, schemaOnly, dataOnly, dropExists, ignoreDependencies, restoreRBAC, rbacOnly, restoreConfigs, configsOnly, resume bool, version string, commandId int) error

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) Upload

func (b *Backuper) Upload(backupName string, deleteSource bool, diffFrom, diffFromRemote, tablePattern string, partitions []string, schemaOnly, resume bool, backupVersion string, commandId int) error

func (*Backuper) ValidateWatchParams

func (b *Backuper) ValidateWatchParams(watchInterval, fullInterval, watchBackupNameTemplate string) error

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

Jump to

Keyboard shortcuts

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