config

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Exist Is config file exist
	Exist bool
	// Models configs
	Models []ModelConfig
	// backup base dir
	VtsBackupDir string = getBackupDir()

	PidFilePath string = filepath.Join(VtsBackupDir, "vtsbackup.pid")
	LogFilePath string = filepath.Join(VtsBackupDir, "vtsbackup.log")
	Web         WebConfig

	// The config file loaded at
	UpdatedAt time.Time
)

Functions

func Init

func Init(configFile string) error

Init loadConfig from: - ./vtsbackup.yml - ~/.vtsbackup/vtsbackup.yml - /etc/vtsbackup/vtsbackup.yml

func OnConfigChange

func OnConfigChange(run func(in fsnotify.Event))

OnConfigChange add callback when config changed

Types

type ModelConfig

type ModelConfig struct {
	Name        string
	Description string
	// WorkDir of the backup started
	WorkDir        string
	TempPath       string
	DumpPath       string
	Schedule       ScheduleConfig
	CompressWith   SubConfig
	EncryptWith    SubConfig
	Archive        *viper.Viper
	Splitter       *viper.Viper
	Storages       map[string]SubConfig
	Notifiers      map[string]SubConfig
	DefaultStorage string
	Viper          *viper.Viper
	BeforeScript   string
	AfterScript    string
}

ModelConfig for special case

func GetModelConfigByName

func GetModelConfigByName(name string) (model *ModelConfig)

GetModelConfigByName get model config by name

type ScheduleConfig

type ScheduleConfig struct {
	Enabled bool `json:"enabled,omitempty"`
	// Cron expression
	Cron string `json:"cron,omitempty"`
	// Every
	Every string `json:"every,omitempty"`
	// At time
	At string `json:"at,omitempty"`
}

func (ScheduleConfig) String

func (sc ScheduleConfig) String() string

type SubConfig

type SubConfig struct {
	Name  string
	Type  string
	Viper *viper.Viper
}

SubConfig sub config info

type WebConfig

type WebConfig struct {
	Host     string
	Port     string
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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