utils

package
v1.2.27 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BackupExample = "backup --dbname database --disable-compression\n" +
	"backup --dbname database --storage s3 --path /custom-path --disable-compression"
View Source
const MainExample = "mysql-bkup backup --dbname database --disable-compression\n" +
	"backup --dbname database --storage s3 --path /custom-path\n" +
	"restore --dbname database --file db_20231219_022941.sql.gz"
View Source
const RestoreExample = "restore --dbname database --file db_20231219_022941.sql.gz\n" +
	"restore --dbname database --storage s3 --path /custom-path --file db_20231219_022941.sql.gz"

Variables

View Source
var DatabaseName = ""
View Source
var Version = ""

Functions

func ChangePermission

func ChangePermission(filePath string, mod int)

func CheckEnvVars

func CheckEnvVars(vars []string) error

CheckEnvVars checks if all the specified environment variables are set

func ConvertBytes added in v1.2.25

func ConvertBytes(bytes uint64) string

ConvertBytes converts bytes to a human-readable string with the appropriate unit (bytes, MiB, or GiB).

func CopyFile

func CopyFile(src, dst string) error

func CronNextTime added in v1.2.20

func CronNextTime(cronExpr string) time.Time

CronNextTime returns cronExpression next time

func DeleteFile

func DeleteFile(filePath string) error

func EnvWithDefault added in v1.2.20

func EnvWithDefault(envName string, defaultValue string) string

func Error

func Error(msg string, args ...interface{})

Error logs error messages

func Fatal

func Fatal(msg string, args ...interface{})

func FileExists

func FileExists(filename string) bool

FileExists checks if the file does exist

func FlagGetBool

func FlagGetBool(cmd *cobra.Command, flagName string) bool

func FlagGetString

func FlagGetString(cmd *cobra.Command, flagName string) string

func GetEnv

func GetEnv(cmd *cobra.Command, flagName, envName string) string

func GetEnvVariable

func GetEnvVariable(envName, oldEnvName string) string

func GetIntEnv added in v1.2.5

func GetIntEnv(envName string) int

func Info

func Info(msg string, args ...interface{})

Info returns info log

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

func IsValidCronExpression added in v1.2.8

func IsValidCronExpression(cronExpr string) bool

IsValidCronExpression verify cronExpression and returns boolean

func MakeDir added in v1.2.3

func MakeDir(dirPath string) error

MakeDir create directory

func MakeDirAll added in v1.2.3

func MakeDirAll(dirPath string) error

MakeDirAll create directory

func NotifyError added in v1.2.5

func NotifyError(error string)

func NotifySuccess added in v1.2.5

func NotifySuccess(notificationData *NotificationData)

func SendEmail added in v1.2.16

func SendEmail(subject, body string) error

func SetEnv

func SetEnv(key, value string)

func TimeFormat added in v1.2.17

func TimeFormat() string

TimeFormat returns the format of the time

func Warn

func Warn(msg string, args ...interface{})

Warn returns warning log

func WriteToFile

func WriteToFile(filePath, content string) error

Types

type ErrorMessage added in v1.2.16

type ErrorMessage struct {
	Database        string
	EndTime         string
	Error           string
	BackupReference string
	DatabaseName    string
}

type MailConfig added in v1.2.16

type MailConfig struct {
	MailHost     string
	MailPort     int
	MailUserName string
	MailPassword string
	MailTo       string
	MailFrom     string
	SkipTls      bool
}

type NotificationData added in v1.2.16

type NotificationData struct {
	File            string
	BackupSize      string
	Database        string
	Duration        string
	Storage         string
	BackupLocation  string
	BackupReference string
}

Jump to

Keyboard shortcuts

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