utils

package
v0.0.0-...-b39db84 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BACKUP_DIR            = "backup-dir"
	COMPRESSION_LEVEL     = "compression-level"
	DATA_ONLY             = "data-only"
	DBNAME                = "dbname"
	DEBUG                 = "debug"
	EXCLUDE_RELATION      = "exclude-table"
	EXCLUDE_RELATION_FILE = "exclude-table-file"
	EXCLUDE_SCHEMA        = "exclude-schema"
	FROM_TIMESTAMP        = "from-timestamp"
	INCLUDE_RELATION      = "include-table"
	INCLUDE_RELATION_FILE = "include-table-file"
	INCLUDE_SCHEMA        = "include-schema"
	INCREMENTAL           = "incremental"
	JOBS                  = "jobs"
	LEAF_PARTITION_DATA   = "leaf-partition-data"
	METADATA_ONLY         = "metadata-only"
	NO_COMPRESSION        = "no-compression"
	PLUGIN_CONFIG         = "plugin-config"
	QUIET                 = "quiet"
	SINGLE_DATA_FILE      = "single-data-file"
	VERBOSE               = "verbose"
	WITH_STATS            = "with-stats"
	CREATE_DB             = "create-db"
	ON_ERROR_CONTINUE     = "on-error-continue"
	REDIRECT_DB           = "redirect-db"
	TIMESTAMP             = "timestamp"
	WITH_GLOBALS          = "with-globals"
)
View Source
const (
	BackupPreventedByGpexpandMessage GpexpandFailureMessage = `Greenplum expansion currently in process, please re-run gpbackup when the expansion has completed`

	RestorePreventedByGpexpandMessage GpexpandFailureMessage = `` /* 268-byte string literal not displayed */

	MasterDataDirQuery                = `select datadir from gp_segment_configuration where content=-1 and role='p'`
	GpexpandTemporaryTableStatusQuery = `SELECT status FROM gpexpand.status ORDER BY updated DESC LIMIT 1`
	GpexpandStatusTableExistsQuery    = `` /* 156-byte string literal not displayed */

	GpexpandStatusFilename = "gpexpand.status"
)
View Source
const (
	PB_NONE = iota
	PB_INFO
	PB_VERBOSE

	//Verbose progress bar logs every 10 percent
	INCR_PERCENT = 10
)

* The following constants are used for determining when to display a progress bar * * PB_INFO only shows in info mode because some methods have a different way of * logging in verbose mode and we don't want them to conflict * PB_VERBOSE show a progress bar in INFO and VERBOSE mode * * A simple incremental progress tracker will be shown in info mode and * in verbose mode we will log progress at increments of 10%

View Source
const MINIMUM_GPDB4_VERSION = "4.3.17"
View Source
const MINIMUM_GPDB5_VERSION = "5.1.0"
View Source
const RequiredPluginVersion = "0.3.0"
View Source
const SecretKeyFile = ".encrypt"

Variables

This section is empty.

Functions

func AppendBackupParams

func AppendBackupParams(infoArr *[]LineInfo, paramsStr string)

func CheckAgentErrorsOnSegments

func CheckAgentErrorsOnSegments(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo) error

func CheckExclusiveFlags

func CheckExclusiveFlags(flags *pflag.FlagSet, flagNames ...string)

At most one of the flags passed to this function may be set

func CheckGpexpandRunning

func CheckGpexpandRunning(errMsg GpexpandFailureMessage)

func CleanUpHelperFilesOnAllHosts

func CleanUpHelperFilesOnAllHosts(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func CleanUpSegmentHelperProcesses

func CleanUpSegmentHelperProcesses(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo, operation string)

func ConstructEmailMessage

func ConstructEmailMessage(timestamp string, contactList string, reportFilePath string, utility string) string

func CopyFile

func CopyFile(src, dest string) error

func CreateFirstSegmentPipeOnAllHosts

func CreateFirstSegmentPipeOnAllHosts(oid string, c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func DollarQuoteString

func DollarQuoteString(literal string) string

Dollar-quoting logic is based on appendStringLiteralDQ() in pg_dump.

func EmailReport

func EmailReport(c *cluster.Cluster, timestamp string, reportFilePath string, utility string)

func EnsureBackupVersionCompatibility

func EnsureBackupVersionCompatibility(backupVersion string, restoreVersion string)

* This function will not error out if the user has gprestore X.Y.Z * and gpbackup X.Y.Z+dev, when technically the uncommitted code changes * in the +dev version of gpbackup may have incompatibilities with the * committed version of gprestore. * * We assume this condition will never arise in practice, as gpbackup and * gprestore will be built with identical versions during development, and * users will never use a +dev version in production.

func EnsureDatabaseVersionCompatibility

func EnsureDatabaseVersionCompatibility(backupGPDBVersion string, restoreGPDBVersion dbconn.GPDBVersion)

func EscapeSingleQuotes

func EscapeSingleQuotes(str string) string

func GetContacts

func GetContacts(filename string, utility string) string

func GetDurationInfo

func GetDurationInfo(timestamp string, endTime time.Time) (string, string, string)

func GetIncludedPartitionRoots

func GetIncludedPartitionRoots(tocDataEntries []MasterDataEntry, includeRelations []string) []string

func GetSecretKey

func GetSecretKey(pluginName string, mdd string) (string, error)

func GetUserAndHostInfo

func GetUserAndHostInfo() (string, string, string)

func HandleSingleDashes

func HandleSingleDashes(args []string) []string

* Convert arguments that contain a single dash to double dashes for backward * compatibility.

func InitializePipeThroughParameters

func InitializePipeThroughParameters(compress bool, compressionLevel int)

func InitializeSignalHandler

func InitializeSignalHandler(cleanupFunc func(), procDesc string, termFlag *bool)

func MakeFQN

func MakeFQN(schema string, object string) string

This function assumes that all identifiers are already appropriately quoted

func MustGetFlagBool

func MustGetFlagBool(cmdFlags *pflag.FlagSet, flagName string) bool

func MustGetFlagInt

func MustGetFlagInt(cmdFlags *pflag.FlagSet, flagName string) int

func MustGetFlagString

func MustGetFlagString(cmdFlags *pflag.FlagSet, flagName string) string

func MustGetFlagStringArray

func MustGetFlagStringArray(cmdFlags *pflag.FlagSet, flagName string) []string

func MustGetFlagStringSlice

func MustGetFlagStringSlice(cmdFlags *pflag.FlagSet, flagName string) []string

func MustPrintBytes

func MustPrintBytes(file io.Writer, bytes []byte) uint64

func MustPrintf

func MustPrintf(file io.Writer, s string, v ...interface{}) uint64

func MustPrintln

func MustPrintln(file io.Writer, v ...interface{}) uint64

func ParseErrorMessage

func ParseErrorMessage(errStr string) string

func PrintObjectCounts

func PrintObjectCounts(reportFile io.WriteCloser, objectCounts map[string]int)

func QuoteIdent

func QuoteIdent(connectionPool *dbconn.DBConn, ident string) string

func SetPipeThroughProgram

func SetPipeThroughProgram(compression PipeThroughProgram)

func SliceToQuotedString

func SliceToQuotedString(slice []string) string

func StartAgent

func StartAgent(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo, operation string, pluginConfigFile string, compressStr string)

func TerminateHangingCopySessions

func TerminateHangingCopySessions(connectionPool *dbconn.DBConn, fpInfo backup_filepath.FilePathInfo, appName string)

TODO: Uniquely identify COPY commands in the multiple data file case to allow terminating sessions

func UnquoteIdent

func UnquoteIdent(ident string) string

func ValidateFQNs

func ValidateFQNs(fqns []string)

func ValidateFullPath

func ValidateFullPath(path string) error

func ValidateGPDBVersionCompatibility

func ValidateGPDBVersionCompatibility(connectionPool *dbconn.DBConn)

func VerifyHelperVersionOnSegments

func VerifyHelperVersionOnSegments(version string, c *cluster.Cluster)

func WriteOidListToSegments

func WriteOidListToSegments(oidList []string, c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func WriteOids

func WriteOids(writer io.Writer, oidList []string) error

func WriteOidsToFile

func WriteOidsToFile(filename string, oidList []string)

func WriteRestoreReportFile

func WriteRestoreReportFile(reportFilename string, backupTimestamp string, startTimestamp string, connectionPool *dbconn.DBConn, restoreVersion string, errMsg string)

Types

type AOEntry

type AOEntry struct {
	Modcount         int64
	LastDDLTimestamp string
}

type ContactFile

type ContactFile struct {
	Contacts map[string][]EmailContact
}

type EmailContact

type EmailContact struct {
	Address string
	Status  map[string]bool
}

type FileWithByteCount

type FileWithByteCount struct {
	Filename string

	ByteCount uint64
	// contains filtered or unexported fields
}

func NewFileWithByteCount

func NewFileWithByteCount(writer io.Writer) *FileWithByteCount

func NewFileWithByteCountFromFile

func NewFileWithByteCountFromFile(filename string) *FileWithByteCount

func (*FileWithByteCount) Close

func (file *FileWithByteCount) Close()

func (*FileWithByteCount) MustPrint

func (file *FileWithByteCount) MustPrint(s string)

func (*FileWithByteCount) MustPrintf

func (file *FileWithByteCount) MustPrintf(s string, v ...interface{})

func (*FileWithByteCount) MustPrintln

func (file *FileWithByteCount) MustPrintln(v ...interface{})

type FilterSet

type FilterSet struct {
	Set                 map[string]bool
	IsExclude           bool
	AlwaysMatchesFilter bool
}

* This set implementation can be used in one of two ways. An "include" set * returns true if an item is in the map and false otherwise, while an "exclude" * set returns false if an item is in the map and true otherwise, so that the * set can be used for filtering on items in lists. * * The alwaysMatchesFilter variable causes MatchesFilter() to always return true * if an empty list is passed, so that it doesn't attempt to filter on anything * The isExclude variable controls whether a set is an include set or an exclude * set.

func NewExcludeSet

func NewExcludeSet(list []string) *FilterSet

func NewIncludeSet

func NewIncludeSet(list []string) *FilterSet

func NewSet

func NewSet(list []string) *FilterSet

func (*FilterSet) Equals

func (s *FilterSet) Equals(s1 *FilterSet) bool

func (*FilterSet) Length

func (s *FilterSet) Length() int

func (*FilterSet) MatchesFilter

func (s *FilterSet) MatchesFilter(item string) bool

type GpexpandFailureMessage

type GpexpandFailureMessage string

type GpexpandSensor

type GpexpandSensor struct {
	// contains filtered or unexported fields
}

func NewGpexpandSensor

func NewGpexpandSensor(myfs vfs.Filesystem, conn *dbconn.DBConn) GpexpandSensor

func (GpexpandSensor) IsGpexpandRunning

func (sensor GpexpandSensor) IsGpexpandRunning() (bool, error)

type IncrementalEntries

type IncrementalEntries struct {
	AO map[string]AOEntry
}

type LineInfo

type LineInfo struct {
	Key   string
	Value string
}

type MasterDataEntry

type MasterDataEntry struct {
	Schema          string
	Name            string
	Oid             uint32
	AttributeString string
	RowsCopied      int64
	PartitionRoot   string
}

type MetadataEntry

type MetadataEntry struct {
	Schema          string
	Name            string
	ObjectType      string
	ReferenceObject string
	StartByte       uint64
	EndByte         uint64
}

type PipeThroughProgram

type PipeThroughProgram struct {
	Name          string
	OutputCommand string
	InputCommand  string
	Extension     string
}

func GetPipeThroughProgram

func GetPipeThroughProgram() PipeThroughProgram

type PluginConfig

type PluginConfig struct {
	ExecutablePath string            `yaml:"executablepath"`
	ConfigPath     string            `yaml:"-"`
	Options        map[string]string `yaml:"options"`
	// contains filtered or unexported fields
}

func ReadPluginConfig

func ReadPluginConfig(configFile string) (*PluginConfig, error)

func (*PluginConfig) BackupFile

func (plugin *PluginConfig) BackupFile(filenamePath string) error

func (*PluginConfig) BackupPluginVersion

func (plugin *PluginConfig) BackupPluginVersion() string

func (*PluginConfig) BackupSegmentTOCs

func (plugin *PluginConfig) BackupSegmentTOCs(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func (*PluginConfig) CheckPluginExistsOnAllHosts

func (plugin *PluginConfig) CheckPluginExistsOnAllHosts(c *cluster.Cluster) string

func (*PluginConfig) CleanupPluginForBackup

func (plugin *PluginConfig) CleanupPluginForBackup(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func (*PluginConfig) CleanupPluginForRestore

func (plugin *PluginConfig) CleanupPluginForRestore(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func (*PluginConfig) CopyPluginConfigToAllHosts

func (plugin *PluginConfig) CopyPluginConfigToAllHosts(c *cluster.Cluster)

func (*PluginConfig) DeletePluginConfigWhenEncrypting

func (plugin *PluginConfig) DeletePluginConfigWhenEncrypting(c *cluster.Cluster)

func (*PluginConfig) GetPluginName

func (plugin *PluginConfig) GetPluginName(c *cluster.Cluster) (pluginName string, err error)

func (*PluginConfig) MustBackupFile

func (plugin *PluginConfig) MustBackupFile(filenamePath string)

func (*PluginConfig) MustRestoreFile

func (plugin *PluginConfig) MustRestoreFile(filenamePath string)

func (*PluginConfig) RestoreSegmentTOCs

func (plugin *PluginConfig) RestoreSegmentTOCs(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func (*PluginConfig) SetBackupPluginVersion

func (plugin *PluginConfig) SetBackupPluginVersion(timestamp string, historicalPluginVersion string)

func (*PluginConfig) SetupPluginForBackup

func (plugin *PluginConfig) SetupPluginForBackup(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func (*PluginConfig) SetupPluginForRestore

func (plugin *PluginConfig) SetupPluginForRestore(c *cluster.Cluster, fpInfo backup_filepath.FilePathInfo)

func (*PluginConfig) UsesEncryption

func (plugin *PluginConfig) UsesEncryption() bool

type PluginScope

type PluginScope string
const (
	MASTER       PluginScope = "master"
	SEGMENT_HOST PluginScope = "segment_host"
	SEGMENT      PluginScope = "segment"
)

type ProgressBar

type ProgressBar interface {
	Start() *pb.ProgressBar
	Finish()
	Increment() int
}

func NewProgressBar

func NewProgressBar(count int, prefix string, showProgressBar int) ProgressBar

type Report

type Report struct {
	BackupParamsString string
	DatabaseSize       string
	backup_history.BackupConfig
}

* This struct holds information that will be printed to the report file * after a backup, as well as information printed to the configuration * file that we will want to read in for a restore.

func (*Report) ConstructBackupParamsString

func (report *Report) ConstructBackupParamsString()

func (*Report) WriteBackupReportFile

func (report *Report) WriteBackupReportFile(reportFilename string, timestamp string, endtime time.Time, objectCounts map[string]int, errMsg string)

type SegmentDataEntry

type SegmentDataEntry struct {
	StartByte uint64
	EndByte   uint64
}

type SegmentTOC

type SegmentTOC struct {
	DataEntries map[uint]SegmentDataEntry
}

func NewSegmentTOC

func NewSegmentTOC(filename string) *SegmentTOC

func (*SegmentTOC) AddSegmentDataEntry

func (toc *SegmentTOC) AddSegmentDataEntry(oid uint, startByte uint64, endByte uint64)

func (*SegmentTOC) WriteToFileAndMakeReadOnly

func (toc *SegmentTOC) WriteToFileAndMakeReadOnly(filename string) error

This function return an error rather than Fataling because it is called by the helper

type StatementWithType

type StatementWithType struct {
	Schema          string
	Name            string
	ObjectType      string
	ReferenceObject string
	Statement       string
}

func RemoveActiveRole

func RemoveActiveRole(activeUser string, statements []StatementWithType) []StatementWithType

func SubstituteRedirectDatabaseInStatements

func SubstituteRedirectDatabaseInStatements(statements []StatementWithType, oldQuotedName string, newQuotedName string) []StatementWithType

type TOC

type TOC struct {
	GlobalEntries       []MetadataEntry
	PredataEntries      []MetadataEntry
	PostdataEntries     []MetadataEntry
	StatisticsEntries   []MetadataEntry
	DataEntries         []MasterDataEntry
	IncrementalMetadata IncrementalEntries
	// contains filtered or unexported fields
}

func NewTOC

func NewTOC(filename string) *TOC

func (*TOC) AddMasterDataEntry

func (toc *TOC) AddMasterDataEntry(schema string, name string, oid uint32, attributeString string, rowsCopied int64, PartitionRoot string)

func (*TOC) AddMetadataEntry

func (toc *TOC) AddMetadataEntry(section string, entry MetadataEntry, start, end uint64)

func (*TOC) GetDataEntriesMatching

func (toc *TOC) GetDataEntriesMatching(includeSchemas []string, excludeSchemas []string,
	includeTableFQNs []string, excludeTableFQNs []string, restorePlanTableFQNs []string) []MasterDataEntry

func (*TOC) GetSQLStatementForObjectTypes

func (toc *TOC) GetSQLStatementForObjectTypes(section string, metadataFile io.ReaderAt, includeObjectTypes []string, excludeObjectTypes []string, includeSchemas []string, excludeSchemas []string, includeRelations []string, excludeRelations []string) []StatementWithType

func (*TOC) InitializeMetadataEntryMap

func (toc *TOC) InitializeMetadataEntryMap()

func (*TOC) WriteToFileAndMakeReadOnly

func (toc *TOC) WriteToFileAndMakeReadOnly(filename string)

type TOCObject

type TOCObject interface {
	GetMetadataEntry() (string, MetadataEntry)
}

type TOCObjectWithMetadata

type TOCObjectWithMetadata interface {
	GetMetadataEntry() (string, MetadataEntry)
	FQN() string
}

type VerboseProgressBar

type VerboseProgressBar struct {
	*pb.ProgressBar
	// contains filtered or unexported fields
}

func NewVerboseProgressBar

func NewVerboseProgressBar(count int, prefix string) *VerboseProgressBar

func (*VerboseProgressBar) Increment

func (vpb *VerboseProgressBar) Increment() int

Jump to

Keyboard shortcuts

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