Documentation ¶
Index ¶
- Constants
- Variables
- func GetDisksByPaths(disks []Disk, dataPaths []string) map[string]string
- type BackupDataSize
- type ClickHouse
- func (ch *ClickHouse) ApplyMacros(ctx context.Context, s string) (string, error)
- func (ch *ClickHouse) ApplyMacrosToObjectLabels(ctx context.Context, objectLabels map[string]string, backupName string) (map[string]string, error)
- func (ch *ClickHouse) ApplyMutation(ctx context.Context, tableMetadata metadata.TableMetadata, ...) error
- func (ch *ClickHouse) AttachDataParts(table metadata.TableMetadata, dstTable Table) error
- func (ch *ClickHouse) AttachTable(ctx context.Context, table metadata.TableMetadata, dstTable Table) error
- func (ch *ClickHouse) CalculateMaxFileSize(ctx context.Context, cfg *config.Config) (int64, error)
- func (ch *ClickHouse) CanShardOperation(ctx context.Context) error
- func (ch *ClickHouse) CheckReplicationInProgress(table metadata.TableMetadata) (bool, error)
- func (ch *ClickHouse) CheckSettingsExists(ctx context.Context, settings map[string]bool) (map[string]bool, error)
- func (ch *ClickHouse) CheckSystemPartsColumns(ctx context.Context, table *Table) error
- func (ch *ClickHouse) CheckTypesConsistency(table *Table, partColumnsDataTypes []ColumnDataTypes) error
- func (ch *ClickHouse) Close()
- func (ch *ClickHouse) Connect() error
- func (ch *ClickHouse) CreateDatabase(database string, cluster string) error
- func (ch *ClickHouse) CreateDatabaseFromQuery(ctx context.Context, query, cluster string, args ...interface{}) error
- func (ch *ClickHouse) CreateDatabaseWithEngine(database, engine, cluster string) error
- func (ch *ClickHouse) CreateTable(table Table, query string, dropTable, ignoreDependencies bool, ...) error
- func (ch *ClickHouse) CreateUserDefinedFunction(name string, query string, cluster string) error
- func (ch *ClickHouse) DropTable(table Table, query string, onCluster string, ignoreDependencies bool, ...) error
- func (ch *ClickHouse) ExtractStoragePolicy(query string) string
- func (ch *ClickHouse) FreezeTable(ctx context.Context, table *Table, name string) error
- func (ch *ClickHouse) FreezeTableByParts(ctx context.Context, table *Table, name string) error
- func (ch *ClickHouse) GetAccessManagementPath(ctx context.Context, disks []Disk) (string, error)
- func (ch *ClickHouse) GetConn() driver.Conn
- func (ch *ClickHouse) GetDatabases(ctx context.Context, cfg *config.Config, tablePattern string) ([]Database, error)
- func (ch *ClickHouse) GetDefaultPath(disks []Disk) (string, error)
- func (ch *ClickHouse) GetDisks(ctx context.Context, enrich bool) ([]Disk, error)
- func (ch *ClickHouse) GetEmbeddedBackupPath(disks []Disk) (string, error)
- func (ch *ClickHouse) GetInProgressMutations(ctx context.Context, database string, table string) ([]metadata.MutationMetadata, error)
- func (ch *ClickHouse) GetPreprocessedConfigPath(ctx context.Context) (string, error)
- func (ch *ClickHouse) GetPreprocessedXMLSettings(ctx context.Context, settingsXPath map[string]string, fileName string) (map[string]string, error)
- func (ch *ClickHouse) GetSettingsValues(ctx context.Context, settings []interface{}) (map[string]string, error)
- func (ch *ClickHouse) GetTables(ctx context.Context, tablePattern string) ([]Table, error)
- func (ch *ClickHouse) GetUserDefinedFunctions(ctx context.Context) ([]Function, error)
- func (ch *ClickHouse) GetVersion(ctx context.Context) (int, error)
- func (ch *ClickHouse) GetVersionDescribe(ctx context.Context) string
- func (ch *ClickHouse) IsAtomic(database string) (bool, error)
- func (ch *ClickHouse) LogQuery(query string, args ...interface{}) string
- func (ch *ClickHouse) ParseXML(ctx context.Context, configName string) (configFile string, doc *xmlquery.Node, err error)
- func (ch *ClickHouse) Query(query string, args ...interface{}) error
- func (ch *ClickHouse) QueryContext(ctx context.Context, query string, args ...interface{}) error
- func (ch *ClickHouse) Select(dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) SelectSingleRow(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) SelectSingleRowNoCtx(dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) ShowCreateTable(ctx context.Context, database, name string) string
- func (ch *ClickHouse) StructSelect(dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) TurnAnalyzerOffIfNecessary(version int, query string, allowExperimentalAnalyzer string) (string, error)
- func (ch *ClickHouse) TurnAnalyzerOnIfNecessary(version int, query string, allowExperimentalAnalyzer string) error
- type ColumnDataTypes
- type Database
- type Disk
- type Function
- type IsSystemTablesFieldPresent
- type Macro
- type RBACObject
- type ShardBackupType
- type SystemBackups
- type Table
- type UserDirectory
Constants ¶
const ( ShardBackupFull = "full" ShardBackupNone = "none" ShardBackupSchema = "schema-only" )
Variables ¶
var (
ErrShardOperationVers = errors.New("sharded operations are only supported for " +
"clickhouse-server >= v21.x")
)
Functions ¶
Types ¶
type BackupDataSize ¶ added in v2.5.0
type BackupDataSize struct {
Size uint64 `ch:"backup_data_size"`
}
BackupDataSize - info from system.parts or system.tables when embedded BACKUP statement return zero size
type ClickHouse ¶
type ClickHouse struct { Config *config.ClickHouseConfig IsOpen bool BreakConnectOnError bool // contains filtered or unexported fields }
ClickHouse - provide
func (*ClickHouse) ApplyMacros ¶
func (*ClickHouse) ApplyMacrosToObjectLabels ¶ added in v2.6.0
func (ch *ClickHouse) ApplyMacrosToObjectLabels(ctx context.Context, objectLabels map[string]string, backupName string) (map[string]string, error)
ApplyMacrosToObjectLabels https://github.com/Altinity/clickhouse-backup/issues/588
func (*ClickHouse) ApplyMutation ¶
func (ch *ClickHouse) ApplyMutation(ctx context.Context, tableMetadata metadata.TableMetadata, mutation metadata.MutationMetadata) error
func (*ClickHouse) AttachDataParts ¶
func (ch *ClickHouse) AttachDataParts(table metadata.TableMetadata, dstTable Table) error
AttachDataParts - execute ALTER TABLE ... ATTACH PART command for specific table
func (*ClickHouse) AttachTable ¶
func (ch *ClickHouse) AttachTable(ctx context.Context, table metadata.TableMetadata, dstTable Table) error
AttachTable - execute ATTACH TABLE command for specific table
func (*ClickHouse) CalculateMaxFileSize ¶
func (*ClickHouse) CanShardOperation ¶
func (ch *ClickHouse) CanShardOperation(ctx context.Context) error
func (*ClickHouse) CheckReplicationInProgress ¶
func (ch *ClickHouse) CheckReplicationInProgress(table metadata.TableMetadata) (bool, error)
CheckReplicationInProgress allow to avoid concurrent ATTACH PART https://github.com/Altinity/clickhouse-backup/issues/474
func (*ClickHouse) CheckSettingsExists ¶
func (*ClickHouse) CheckSystemPartsColumns ¶
func (ch *ClickHouse) CheckSystemPartsColumns(ctx context.Context, table *Table) error
CheckSystemPartsColumns check data parts types consistency https://github.com/Altinity/clickhouse-backup/issues/529#issuecomment-1554460504
func (*ClickHouse) CheckTypesConsistency ¶ added in v2.4.24
func (ch *ClickHouse) CheckTypesConsistency(table *Table, partColumnsDataTypes []ColumnDataTypes) error
func (*ClickHouse) Connect ¶
func (ch *ClickHouse) Connect() error
Connect - establish connection to ClickHouse
func (*ClickHouse) CreateDatabase ¶
func (ch *ClickHouse) CreateDatabase(database string, cluster string) error
CreateDatabase - create ClickHouse database
func (*ClickHouse) CreateDatabaseFromQuery ¶
func (ch *ClickHouse) CreateDatabaseFromQuery(ctx context.Context, query, cluster string, args ...interface{}) error
func (*ClickHouse) CreateDatabaseWithEngine ¶
func (ch *ClickHouse) CreateDatabaseWithEngine(database, engine, cluster string) error
func (*ClickHouse) CreateTable ¶
func (ch *ClickHouse) CreateTable(table Table, query string, dropTable, ignoreDependencies bool, onCluster string, version int, defaultDataPath string) error
CreateTable - create ClickHouse table
func (*ClickHouse) CreateUserDefinedFunction ¶
func (ch *ClickHouse) CreateUserDefinedFunction(name string, query string, cluster string) error
func (*ClickHouse) DropTable ¶
func (ch *ClickHouse) DropTable(table Table, query string, onCluster string, ignoreDependencies bool, version int, defaultDataPath string) error
DropTable - drop ClickHouse table
func (*ClickHouse) ExtractStoragePolicy ¶ added in v2.4.26
func (ch *ClickHouse) ExtractStoragePolicy(query string) string
func (*ClickHouse) FreezeTable ¶
FreezeTable - freeze all partitions for table This way available for ClickHouse since v19.1
func (*ClickHouse) FreezeTableByParts ¶ added in v2.5.0
FreezeTableByParts - freeze all partitions in table one by one also ally `freeze_by_part_where`
func (*ClickHouse) GetAccessManagementPath ¶
GetAccessManagementPath extract path from following sources system.user_directories, access_control_path from /var/lib/clickhouse/preprocessed_configs/config.xml, system.disks
func (*ClickHouse) GetConn ¶
func (ch *ClickHouse) GetConn() driver.Conn
GetConn - return current connection
func (*ClickHouse) GetDatabases ¶
func (ch *ClickHouse) GetDatabases(ctx context.Context, cfg *config.Config, tablePattern string) ([]Database, error)
GetDatabases - return slice of all non system databases for backup
func (*ClickHouse) GetDefaultPath ¶
func (ch *ClickHouse) GetDefaultPath(disks []Disk) (string, error)
func (*ClickHouse) GetEmbeddedBackupPath ¶
func (ch *ClickHouse) GetEmbeddedBackupPath(disks []Disk) (string, error)
func (*ClickHouse) GetInProgressMutations ¶
func (ch *ClickHouse) GetInProgressMutations(ctx context.Context, database string, table string) ([]metadata.MutationMetadata, error)
func (*ClickHouse) GetPreprocessedConfigPath ¶
func (ch *ClickHouse) GetPreprocessedConfigPath(ctx context.Context) (string, error)
func (*ClickHouse) GetPreprocessedXMLSettings ¶
func (ch *ClickHouse) GetPreprocessedXMLSettings(ctx context.Context, settingsXPath map[string]string, fileName string) (map[string]string, error)
GetPreprocessedXMLSettings - @todo think about from_end and from_zookeeper corner cases
func (*ClickHouse) GetSettingsValues ¶ added in v2.6.3
func (*ClickHouse) GetTables ¶
GetTables - return slice of all tables suitable for backup, MySQL and PostgresSQL database engine shall be skipped
func (*ClickHouse) GetUserDefinedFunctions ¶
func (ch *ClickHouse) GetUserDefinedFunctions(ctx context.Context) ([]Function, error)
func (*ClickHouse) GetVersion ¶
func (ch *ClickHouse) GetVersion(ctx context.Context) (int, error)
GetVersion - returned ClickHouse version in number format Example value: 19001005
func (*ClickHouse) GetVersionDescribe ¶
func (ch *ClickHouse) GetVersionDescribe(ctx context.Context) string
func (*ClickHouse) LogQuery ¶
func (ch *ClickHouse) LogQuery(query string, args ...interface{}) string
func (*ClickHouse) Query ¶
func (ch *ClickHouse) Query(query string, args ...interface{}) error
func (*ClickHouse) QueryContext ¶
func (ch *ClickHouse) QueryContext(ctx context.Context, query string, args ...interface{}) error
func (*ClickHouse) Select ¶
func (ch *ClickHouse) Select(dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) SelectContext ¶
func (ch *ClickHouse) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) SelectSingleRow ¶
func (ch *ClickHouse) SelectSingleRow(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) SelectSingleRowNoCtx ¶
func (ch *ClickHouse) SelectSingleRowNoCtx(dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) ShowCreateTable ¶
func (ch *ClickHouse) ShowCreateTable(ctx context.Context, database, name string) string
func (*ClickHouse) StructSelect ¶
func (ch *ClickHouse) StructSelect(dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) TurnAnalyzerOffIfNecessary ¶ added in v2.5.11
func (*ClickHouse) TurnAnalyzerOnIfNecessary ¶ added in v2.5.11
func (ch *ClickHouse) TurnAnalyzerOnIfNecessary(version int, query string, allowExperimentalAnalyzer string) error
type ColumnDataTypes ¶ added in v2.4.24
ColumnDataTypes - info from system.parts_columns
type Database ¶
type Database struct { Name string `ch:"name"` Engine string `ch:"engine"` Query string `ch:"query"` }
Database - Clickhouse system.databases struct
type IsSystemTablesFieldPresent ¶
type IsSystemTablesFieldPresent struct { IsDataPathPresent uint64 `ch:"is_data_path_present"` IsDataPathsPresent uint64 `ch:"is_data_paths_present"` IsUUIDPresent uint64 `ch:"is_uuid_present"` IsCreateTableQueryPresent uint64 `ch:"is_create_table_query_present"` IsTotalBytesPresent uint64 `ch:"is_total_bytes_present"` }
IsSystemTablesFieldPresent - ClickHouse `system.tables` varius field flags
type RBACObject ¶ added in v2.5.0
type ShardBackupType ¶
type ShardBackupType string
type SystemBackups ¶
type SystemBackups struct { Id string `ch:"id"` UUID string `ch:"uuid"` BackupName string `ch:"backup_name"` Name string `ch:"name"` Status string `ch:"status"` StatusChangedTime time.Time `ch:"status_changed_time"` Error string `ch:"error"` Internal bool `ch:"internal"` StartTime time.Time `ch:"start_time"` EndTime time.Time `ch:"end_time"` CompressedSize uint64 `ch:"compressed_size"` UncompressedSize uint64 `ch:"uncompressed_size"` NumFiles uint64 `ch:"num_files"` }
SystemBackups - info from system.backups
type Table ¶
type Table struct { // common fields for all `clickhouse-server` versions Database string `ch:"database"` Name string `ch:"name"` Engine string `ch:"engine"` // fields depends on `clickhouse-server` version DataPath string `ch:"data_path"` DataPaths []string `ch:"data_paths"` UUID string `ch:"uuid"` CreateTableQuery string `ch:"create_table_query"` TotalBytes uint64 `ch:"total_bytes"` Skip bool BackupType ShardBackupType }
Table - ClickHouse table struct
type UserDirectory ¶ added in v2.5.0
type UserDirectory struct {
Name string `ch:"name"`
}