config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRoot = "/etc/zackup"

DefaultRoot is the fallback directory.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostConfigs

type HostConfigs map[string]*JobConfig

HostConfigs maps hostnames to config.

type JobConfig

type JobConfig struct {
	SSH   *SSHConfig   `yaml:"ssh"`
	RSync *RsyncConfig `yaml:"rsync"`

	PreScript  Script `yaml:"pre_script"`  // from yaml file
	PostScript Script `yaml:"post_script"` // from yaml file
	// contains filtered or unexported fields
}

JobConfig holds config settings for a single backup job.

func (*JobConfig) Host

func (j *JobConfig) Host() string

Host returns the hostname for this job.

type RsyncConfig

type RsyncConfig struct {
	Included  []string `yaml:"include"`
	Excluded  []string `yaml:"exclude"`
	Arguments []string `yaml:"args"`

	// OverrideGlobalInclude (and other OverrideGlobal* fields) inhibits
	// the inheritance of global Included values (or other fields) when
	// set to true.
	OverrideGlobalInclude   bool `yaml:"override_global_include"`
	OverrideGlobalExclude   bool `yaml:"override_global_exclude"` // see OverrideGlobalInclude
	OverrideGlobalArguments bool `yaml:"override_global_args"`    // see OverrideGlobalInclude
}

RsyncConfig holds config value for the rsync binary.

func (*RsyncConfig) BuildArgVector

func (r *RsyncConfig) BuildArgVector(ssh, src, dst string) []string

BuildArgVector creates an ARGV for rsync.

type SSHConfig

type SSHConfig struct {
	User    string `yaml:"user"`    // defaults to "root"
	Port    uint16 `yaml:"port"`    // defaults to 22
	Timeout *uint  `yaml:"timeout"` // number of seconds, defaults to 15
}

SSHConfig holds connection parameters.

type Script

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

Script is a set of script lines.

func (*Script) Lines

func (s *Script) Lines() []string

Lines returns the combined inline and file script lines (in that order).

func (*Script) UnmarshalYAML

func (s *Script) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type ServiceConfig

type ServiceConfig struct {
	Parallel    uint8  `yaml:"parallel"`
	RootDataset string `yaml:"root_dataset"`
	MountBase   string `yaml:"mount_base"`
	LogLevel    string `yaml:"log_level"`

	RSyncPath string `yaml:"rsync_bin"`
	SSHPath   string `yaml:"ssh_bin"`

	Daemon struct {
		Schedule schedule `yaml:"schedule"`
		Jitter   duration `yaml:"jitter"`
	} `yaml:"daemon"`
}

ServiceConfig represents application-level config options.

func (*ServiceConfig) NextSchedule

func (s *ServiceConfig) NextSchedule(ref time.Time) time.Time

NextSchedule returns the next schedule time. It applies the configured jitter, so the result is not be stable (i.e. neither is it monotonically decreasing for increasing reference times, nor returns it the same duration for the same ref).

type Tree

type Tree interface {
	// SetRoot updates the root config directory. If the given path
	// is different than the previously setup path, the config tree is
	// reloaded.
	SetRoot(newRoot string) error

	// Root returns the path to the root config directory. Might be empty.
	Root() string

	// GetHosts returns the list of configured hosts.
	Hosts() []string

	// GetHost returns a copy of the job description for a single host.
	// If the host is unknown, this returns nil.
	Host(name string) *JobConfig

	// Service returns a copy of the current service configuration.
	Service() *ServiceConfig
}

Tree is the internal representation of the configuration directory passed in as ROOT_DIR flag/env var.

func NewTree

func NewTree(root string) Tree

NewTree returns an empty Tree.

Jump to

Keyboard shortcuts

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