config

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatTOML = "toml"
	FormatYAML = "yaml"
	FormatJSON = "json"
	FormatHCL  = "hcl"
)
View Source
const (
	// ScheduleLockModeDefault waits on acquiring a lock (local and repository) for up to ScheduleConfig lockWait (duration), before failing a schedule.
	// With lockWait set to 0, ScheduleLockModeDefault and ScheduleLockModeFail behave the same.
	ScheduleLockModeDefault = ScheduleLockMode(0)
	// ScheduleLockModeFail fails immediately on a lock failure without waiting.
	ScheduleLockModeFail = ScheduleLockMode(1)
	// ScheduleLockModeIgnore does not create or fail on resticprofile locks. Repository locks cause an immediate failure.
	ScheduleLockModeIgnore = ScheduleLockMode(2)
)
View Source
const ConfidentialReplacement = "×××"

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func CompareSchedules added in v0.27.0

func CompareSchedules(a, b *Schedule) int

func ExcludeProfileProperty added in v0.21.0

func ExcludeProfileProperty(sectionName, propertyName string)

ExcludeProfileProperty allows to exclude a section from the profile. To be used for overlapping commands used by restic and resticprofile.

func ExcludeProfileSection added in v0.21.0

func ExcludeProfileSection(sectionName string)

ExcludeProfileSection allows to exclude a section from the profile. To be used for overlapping commands used by restic and resticprofile.

func GetDeclaredSectionsWith added in v0.21.0

func GetDeclaredSectionsWith[T any](p *Profile) (sections map[string]T)

GetDeclaredSectionsWith returns all sections that implement a certain interface (including nil values)

func GetNonConfidentialArgs added in v0.15.0

func GetNonConfidentialArgs(profile *Profile, args *shell.Args) *shell.Args

GetNonConfidentialArgs returns new shell.Args with confidential values being replaced with their public representation

func GetNonConfidentialValues added in v0.15.0

func GetNonConfidentialValues(profile *Profile, values []string) []string

GetNonConfidentialValues returns a new list with confidential values being replaced with their public representation

func GetSectionWith added in v0.21.0

func GetSectionWith[T any](p *Profile, name string) (result T, ok bool)

GetSectionWith returns a section that implement a certain interface (excluding nil values)

func GetSectionsWith added in v0.21.0

func GetSectionsWith[T any](p *Profile) (sections map[string]T)

GetSectionsWith returns all sections that implement a certain interface (excluding nil values)

func ProcessConfidentialEnvironment added in v0.27.0

func ProcessConfidentialEnvironment(env map[string]ConfidentialValue)

ProcessConfidentialEnvironment hides confidential parts inside the specified environment.

func ProcessConfidentialValues added in v0.15.0

func ProcessConfidentialValues(profile *Profile)

ProcessConfidentialValues hides confidential parts inside the specified Profile.

func ShowStruct added in v0.8.1

func ShowStruct(w io.Writer, orig any, name string) error

ShowStruct write out to w a human-readable text representation of the orig parameter

Types

type BackupSection

type BackupSection struct {
	SectionWithScheduleAndMonitoring `mapstructure:",squash"`
	RunShellCommandsSection          `mapstructure:",squash"`

	CheckBefore       bool     `mapstructure:"check-before" description:"Check the repository before starting the backup command"`
	CheckAfter        bool     `mapstructure:"check-after" description:"Check the repository after the backup command succeeded"`
	UseStdin          bool     `mapstructure:"stdin" argument:"stdin"`
	StdinCommand      []string `` /* 175-byte string literal not displayed */
	SourceRelative    bool     `` /* 230-byte string literal not displayed */
	SourceBase        string   `` /* 207-byte string literal not displayed */
	Source            []string `mapstructure:"source" examples:"/opt/;/home/user/;C:\\Users\\User\\Documents" description:"The paths to backup"`
	Exclude           []string `mapstructure:"exclude" argument:"exclude" argument-type:"no-glob"`
	Iexclude          []string `mapstructure:"iexclude" argument:"iexclude" argument-type:"no-glob"`
	ExcludeFile       []string `mapstructure:"exclude-file" argument:"exclude-file"`
	IexcludeFile      []string `mapstructure:"iexclude-file" argument:"iexclude-file"`
	FilesFrom         []string `mapstructure:"files-from" argument:"files-from"`
	FilesFromRaw      []string `mapstructure:"files-from-raw" argument:"files-from-raw"`
	FilesFromVerbatim []string `mapstructure:"files-from-verbatim" argument:"files-from-verbatim"`
	ExtendedStatus    bool     `mapstructure:"extended-status" argument:"json"`
	NoErrorOnWarning  bool     `mapstructure:"no-error-on-warning" description:"Do not fail the backup when some files could not be read"`
	// contains filtered or unexported fields
}

BackupSection contains the specific configuration to the 'backup' command

func (*BackupSection) IsEmpty added in v0.17.0

func (s *BackupSection) IsEmpty() bool

type ConfidentialValue added in v0.15.0

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

ConfidentialValue is a string value with a public and a confidential representation

func NewConfidentialValue added in v0.15.0

func NewConfidentialValue(value string) ConfidentialValue

func (*ConfidentialValue) IsConfidential added in v0.15.0

func (c *ConfidentialValue) IsConfidential() bool

func (ConfidentialValue) MarshalJSON added in v0.27.0

func (c ConfidentialValue) MarshalJSON() ([]byte, error)

func (ConfidentialValue) String added in v0.15.0

func (c ConfidentialValue) String() string

String returns the masked representation of a value, if confidential It returns the original value if not confidential

func (*ConfidentialValue) UnmarshalJSON added in v0.27.0

func (c *ConfidentialValue) UnmarshalJSON(data []byte) (err error)

func (ConfidentialValue) Value added in v0.15.0

func (c ConfidentialValue) Value() string

Value returns the unmasked original value

type Config added in v0.8.0

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

Config wraps up a viper configuration object

func Load added in v0.8.0

func Load(input io.Reader, format string) (config *Config, err error)

Load configuration from reader This should only be used for unit tests

func LoadFile added in v0.8.0

func LoadFile(configFile, format string) (config *Config, err error)

LoadFile loads configuration from file Leave format blank for auto-detection from the file extension

func (*Config) ClearConfigurationIssues added in v0.23.0

func (c *Config) ClearConfigurationIssues()

ClearConfigurationIssues removes all configuration issues

func (*Config) DisplayConfigurationIssues added in v0.17.0

func (c *Config) DisplayConfigurationIssues()

DisplayConfigurationIssues logs issues in the configuration for all profiles previously returned by GetProfile

func (*Config) Get added in v0.8.0

func (c *Config) Get(key ...string) interface{}

Get the value from the key

func (*Config) GetConfigFile added in v0.8.0

func (c *Config) GetConfigFile() string

GetConfigFile returns the config file used

func (*Config) GetGlobalSection added in v0.8.0

func (c *Config) GetGlobalSection() (*Global, error)

GetGlobalSection returns the global configuration

func (*Config) GetGroupNames added in v0.27.0

func (c *Config) GetGroupNames() (names []string)

func (*Config) GetProfile added in v0.8.0

func (c *Config) GetProfile(profileKey string) (profile *Profile, err error)

GetProfile in configuration. If the profile is not found, it returns errNotFound

func (*Config) GetProfileGroup added in v0.8.0

func (c *Config) GetProfileGroup(groupKey string) (*Group, error)

GetProfileGroup returns the list of profiles in a group

func (*Config) GetProfileGroups added in v0.8.0

func (c *Config) GetProfileGroups() map[string]*Group

GetProfileGroups returns all groups from the configuration

If the groups section does not exist, it returns an empty map

func (*Config) GetProfileNames added in v0.17.0

func (c *Config) GetProfileNames() (names []string)

GetProfileNames returns all profile names defined in the configuration

func (*Config) GetProfiles added in v0.17.0

func (c *Config) GetProfiles() map[string]*Profile

GetProfiles returns a map of all available profiles with their configuration

func (*Config) GetVersion added in v0.16.1

func (c *Config) GetVersion() Version

GetVersion returns the version of the configuration file. Default is Version01 if not specified or invalid

func (*Config) HasProfile added in v0.8.0

func (c *Config) HasProfile(profileKey string) bool

HasProfile returns true if the profile exists in the configuration

func (*Config) HasProfileGroup added in v0.8.0

func (c *Config) HasProfileGroup(groupKey string) bool

HasProfileGroup returns true if the group of profiles exists in the configuration

func (*Config) IsSet added in v0.8.0

func (c *Config) IsSet(key ...string) bool

IsSet checks if the key contains a value. Key and subkey can be queried with IsSet(key, subkey) or by separating them with keyDelim.

type CopySection added in v0.16.0

type CopySection struct {
	SectionWithScheduleAndMonitoring `mapstructure:",squash"`
	RunShellCommandsSection          `mapstructure:",squash"`
	Initialize                       bool              `mapstructure:"initialize" description:"Initialize the secondary repository if missing"`
	InitializeCopyChunkerParams      maybe.Bool        `` /* 141-byte string literal not displayed */
	Repository                       ConfidentialValue `mapstructure:"repository" description:"Destination repository to copy snapshots to"`
	RepositoryFile                   string            `mapstructure:"repository-file" description:"File from which to read the destination repository location to copy snapshots to"`
	PasswordFile                     string            `mapstructure:"password-file" description:"File to read the destination repository password from"`
	PasswordCommand                  string            `mapstructure:"password-command" description:"Shell command to obtain the destination repository password from"`
	KeyHint                          string            `mapstructure:"key-hint" description:"Key ID of key to try decrypting the destination repository first"`
	Snapshots                        []string          `mapstructure:"snapshot" description:"Snapshot IDs to copy (if empty, all snapshots are copied)"`
}

CopySection contains the destination parameters for a copy command

func (*CopySection) IsEmpty added in v0.17.0

func (s *CopySection) IsEmpty() bool

type Display added in v0.11.0

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

Display is a temporary struct to display a config object to the console

func (*Display) Flush added in v0.11.0

func (d *Display) Flush()

type Empty added in v0.17.0

type Empty interface {
	IsEmpty() bool
}

Empty allows to test if a section is specified or not

type Entry added in v0.11.0

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

Entry of configuration to display to the console

type GenericSection added in v0.20.0

type GenericSection struct {
	OtherFlagsSection       `mapstructure:",squash"`
	RunShellCommandsSection `mapstructure:",squash"`
}

GenericSection is used for all restic commands that are not covered in specific section types

func (*GenericSection) IsEmpty added in v0.20.0

func (g *GenericSection) IsEmpty() bool

type Global

type Global struct {
	IONice               bool                `` /* 161-byte string literal not displayed */
	IONiceClass          int                 `` /* 134-byte string literal not displayed */
	IONiceLevel          int                 `` /* 134-byte string literal not displayed */
	Nice                 int                 `` /* 141-byte string literal not displayed */
	Priority             string              `` /* 179-byte string literal not displayed */
	DefaultCommand       string              `` /* 137-byte string literal not displayed */
	Initialize           bool                `mapstructure:"initialize" default:"false" description:"Initialize a repository if missing"`
	NoAutoRepositoryFile maybe.Bool          `` /* 155-byte string literal not displayed */
	ResticBinary         string              `mapstructure:"restic-binary" description:"Full path of the restic executable (detected if not set)"`
	ResticVersion        string              // not configurable at the moment. To be set after ResticBinary is known.
	FilterResticFlags    bool                `` /* 138-byte string literal not displayed */
	ResticLockRetryAfter time.Duration       `` /* 197-byte string literal not displayed */
	ResticStaleLockAge   time.Duration       `` /* 237-byte string literal not displayed */
	ShellBinary          []string            `` /* 152-byte string literal not displayed */
	MinMemory            uint64              `` /* 184-byte string literal not displayed */
	Scheduler            string              `` /* 611-byte string literal not displayed */
	ScheduleDefaults     *ScheduleBaseConfig `mapstructure:"schedule-defaults" default:"" description:"Sets defaults for all schedules"`
	Log                  string              `` /* 295-byte string literal not displayed */
	CommandOutput        string              `` /* 397-byte string literal not displayed */
	LegacyArguments      bool                `` /* 148-byte string literal not displayed */
	SystemdUnitTemplate  string              `` /* 194-byte string literal not displayed */
	SystemdTimerTemplate string              `` /* 196-byte string literal not displayed */
	SenderTimeout        time.Duration       `` /* 204-byte string literal not displayed */
	CACertificates       []string            `` /* 240-byte string literal not displayed */
	PreventSleep         bool                `` /* 190-byte string literal not displayed */
	GroupContinueOnError bool                `` /* 160-byte string literal not displayed */
}

Global holds the configuration from the global section

func NewGlobal added in v0.14.0

func NewGlobal() *Global

NewGlobal instantiates a new Global with default values

func (*Global) SetRootPath added in v0.16.0

func (p *Global) SetRootPath(rootPath string)

type Group added in v0.16.1

type Group struct {
	Name             string                     `show:"noshow"`
	Description      string                     `mapstructure:"description" description:"Describe the group"`
	Profiles         []string                   `mapstructure:"profiles" description:"Names of the profiles belonging to this group"`
	ContinueOnError  maybe.Bool                 `` /* 151-byte string literal not displayed */
	CommandSchedules map[string]*ScheduleConfig `mapstructure:"schedules" description:"Allows to run the group on schedule for the specified command name."`
	// contains filtered or unexported fields
}

Group of profiles

func NewGroup added in v0.27.0

func NewGroup(c *Config, name string) (g *Group)

func (*Group) ResolveConfiguration added in v0.27.0

func (g *Group) ResolveConfiguration()

func (*Group) Schedules added in v0.27.0

func (g *Group) Schedules() map[string]*Schedule

type InitSection added in v0.18.0

type InitSection struct {
	OtherFlagsSection   `mapstructure:",squash"`
	CopyChunkerParams   bool              `mapstructure:"copy-chunker-params" argument:"copy-chunker-params"`
	FromKeyHint         string            `mapstructure:"from-key-hint" argument:"from-key-hint"`
	FromRepository      ConfidentialValue `mapstructure:"from-repository" argument:"from-repo"`
	FromRepositoryFile  string            `mapstructure:"from-repository-file" argument:"from-repository-file"`
	FromPasswordFile    string            `mapstructure:"from-password-file" argument:"from-password-file"`
	FromPasswordCommand string            `mapstructure:"from-password-command" argument:"from-password-command"`
}

InitSection contains the specific configuration to the 'init' command

func (*InitSection) IsEmpty added in v0.19.0

func (i *InitSection) IsEmpty() bool

type Monitoring added in v0.19.0

type Monitoring interface {
	GetSendMonitoring() *SendMonitoringSections
}

Monitoring provides access to http hooks inside a section

type Named added in v0.21.0

type Named interface {
	// Name provides the name of the item
	Name() string
	// Description provides a possibly empty description of the item
	Description() string
}

Named provides Name and Description for an item

type NamedPropertySet added in v0.21.0

type NamedPropertySet interface {
	Named
	PropertySet
}

NamedPropertySet is Named and PropertySet

func NewGlobalInfo added in v0.21.0

func NewGlobalInfo() NamedPropertySet

NewGlobalInfo returns structural information on the "global" config section

func NewGroupInfo added in v0.21.0

func NewGroupInfo() NamedPropertySet

NewGroupInfo returns structural information on the "group" config v2 section

func NewMixinUseInfo added in v0.21.0

func NewMixinUseInfo() NamedPropertySet

NewMixinUseInfo returns structural information on the mixin "use" flags in config v2

func NewMixinsInfo added in v0.21.0

func NewMixinsInfo() NamedPropertySet

NewMixinsInfo returns structural information on the "mixins" config v2 section

func NewScheduleConfigInfo added in v0.27.0

func NewScheduleConfigInfo() NamedPropertySet

NewScheduleConfigInfo returns structural information on the "schedule" config structure

type NumericRange added in v0.21.0

type NumericRange struct {
	From, To                   *float64
	FromExclusive, ToExclusive bool
}

NumericRange holds a numeric range constraint of a PropertyInfo

type OtherFlags added in v0.19.0

type OtherFlags interface {
	GetOtherFlags() map[string]any
}

OtherFlags provides access to dynamic commandline flags

type OtherFlagsSection added in v0.19.0

type OtherFlagsSection struct {
	OtherFlags map[string]any `mapstructure:",remain"`
}

OtherFlagsSection contains additional restic command line flags

func (*OtherFlagsSection) GetOtherFlags added in v0.19.0

func (o *OtherFlagsSection) GetOtherFlags() map[string]any

func (*OtherFlagsSection) SetOtherFlag added in v0.23.0

func (o *OtherFlagsSection) SetOtherFlag(name string, value any)

type Profile

type Profile struct {
	RunShellCommandsSection `mapstructure:",squash"`
	OtherFlagsSection       `mapstructure:",squash"`

	Name                 string
	Description          string                            `mapstructure:"description" description:"Describes the profile"`
	BaseDir              string                            `` /* 199-byte string literal not displayed */
	Quiet                bool                              `mapstructure:"quiet" argument:"quiet"`
	Verbose              int                               `mapstructure:"verbose" argument:"verbose"`
	KeyHint              string                            `mapstructure:"key-hint" argument:"key-hint"`
	Repository           ConfidentialValue                 `mapstructure:"repository" argument:"repo"`
	RepositoryFile       string                            `mapstructure:"repository-file" argument:"repository-file"`
	PasswordFile         string                            `mapstructure:"password-file" argument:"password-file"`
	PasswordCommand      string                            `mapstructure:"password-command" argument:"password-command"`
	CacheDir             string                            `mapstructure:"cache-dir" argument:"cache-dir"`
	CACert               string                            `mapstructure:"cacert" argument:"cacert"`
	TLSClientCert        string                            `mapstructure:"tls-client-cert" argument:"tls-client-cert"`
	Initialize           bool                              `mapstructure:"initialize" default:"" description:"Initialize the restic repository if missing"`
	Inherit              string                            `mapstructure:"inherit" show:"noshow" description:"Name of the profile to inherit all of the settings from"`
	Lock                 string                            `mapstructure:"lock" description:"Path to the lock file to use with resticprofile locks"`
	ForceLock            bool                              `mapstructure:"force-inactive-lock" description:"Allows to lock when the existing lock is considered stale"`
	StreamError          []StreamErrorSection              `mapstructure:"stream-error" description:"Run shell command(s) when a pattern matches the stderr of restic"`
	StatusFile           string                            `mapstructure:"status-file" description:"Path to the status file to update with a summary of last restic command result"`
	PrometheusSaveToFile string                            `` /* 147-byte string literal not displayed */
	PrometheusPush       string                            `` /* 149-byte string literal not displayed */
	PrometheusPushJob    string                            `` /* 135-byte string literal not displayed */
	PrometheusPushFormat string                            `` /* 126-byte string literal not displayed */
	PrometheusLabels     map[string]string                 `mapstructure:"prometheus-labels" description:"Additional prometheus labels to set"`
	SystemdDropInFiles   []string                          `` /* 185-byte string literal not displayed */
	Environment          map[string]ConfidentialValue      `` /* 177-byte string literal not displayed */
	EnvironmentFiles     []string                          `mapstructure:"env-file" description:"Additional dotenv files to load and set as environment in any child process"`
	Init                 *InitSection                      `mapstructure:"init"`
	Backup               *BackupSection                    `mapstructure:"backup"`
	Retention            *RetentionSection                 `mapstructure:"retention" command:"forget"`
	Check                *SectionWithScheduleAndMonitoring `mapstructure:"check"`
	Prune                *SectionWithScheduleAndMonitoring `mapstructure:"prune"`
	Forget               *SectionWithScheduleAndMonitoring `mapstructure:"forget"`
	Copy                 *CopySection                      `mapstructure:"copy"`
	OtherSections        map[string]*GenericSection        `show:",remain"`
	// contains filtered or unexported fields
}

Profile contains the whole profile configuration

func NewProfile

func NewProfile(c *Config, name string) (p *Profile)

NewProfile instantiates a new blank profile

func (*Profile) AllSections added in v0.21.0

func (p *Profile) AllSections() (sections map[string]any)

AllSections returns all possible sections of this profile (including undefined sections set to nil)

func (*Profile) DefinedCommands added in v0.17.0

func (p *Profile) DefinedCommands() (commands []string)

DefinedCommands returns all commands (also called sections) defined in the profile (backup, check, forget, etc.)

func (*Profile) GetBackupSource

func (p *Profile) GetBackupSource() []string

GetBackupSource returns the directories to back up

func (*Profile) GetCommandFlags

func (p *Profile) GetCommandFlags(command string) (flags *shell.Args)

GetCommandFlags returns the flags specific to the command (backup, snapshots, forget, etc.)

func (*Profile) GetCommonFlags

func (p *Profile) GetCommonFlags() (flags *shell.Args)

GetCommonFlags returns the flags common to all commands

func (*Profile) GetCopyInitializeFlags added in v0.21.0

func (p *Profile) GetCopyInitializeFlags() (args *shell.Args)

GetCopyInitializeFlags returns the flags specific to the "init" command when used to initialize the copy destination

func (*Profile) GetCopySnapshotIDs added in v0.26.0

func (p *Profile) GetCopySnapshotIDs() []string

GetCopySnapshotIDs returns the snapshot IDs to copy

func (*Profile) GetEnvironment added in v0.27.0

func (p *Profile) GetEnvironment(withOs bool) (env *util.Environment)

func (*Profile) GetMonitoringSections added in v0.18.0

func (p *Profile) GetMonitoringSections(command string) (monitoring SendMonitoringSections)

func (*Profile) GetRetentionFlags

func (p *Profile) GetRetentionFlags() *shell.Args

GetRetentionFlags returns the flags specific to the "forget" command being run as part of a backup

func (*Profile) GetRunShellCommandsSections added in v0.19.0

func (p *Profile) GetRunShellCommandsSections(command string) (profileCommands RunShellCommandsSection, sectionCommands RunShellCommandsSection)

func (*Profile) HasDeprecatedRetentionSchedule added in v0.11.0

func (p *Profile) HasDeprecatedRetentionSchedule() bool

HasDeprecatedRetentionSchedule indicates if there's one or more schedule parameters in the retention section, which is deprecated as of 0.11.0

func (*Profile) ResolveConfiguration added in v0.17.0

func (p *Profile) ResolveConfiguration()

ResolveConfiguration resolves dependencies between profile config flags

func (*Profile) SchedulableCommands added in v0.12.0

func (p *Profile) SchedulableCommands() (commands []string)

SchedulableCommands returns all command names that could have a schedule

func (*Profile) Schedules added in v0.9.0

func (p *Profile) Schedules() map[string]*Schedule

Schedules returns a map of command -> Schedule, for all the commands that have a schedule configuration Only v1 configuration have schedules inside the profile

func (*Profile) SetHost

func (p *Profile) SetHost(hostname string)

SetHost will replace any host value from a boolean to the hostname

func (*Profile) SetLegacyArg added in v0.15.0

func (p *Profile) SetLegacyArg(legacy bool)

SetLegacyArg is used to activate the legacy (broken) mode of sending arguments on the restic command line

func (*Profile) SetPath added in v0.17.0

func (p *Profile) SetPath(basePath string, sourcePaths ...string)

SetPath will replace any path value from a boolean to sourcePaths and change paths to absolute

func (*Profile) SetResticVersion added in v0.21.0

func (p *Profile) SetResticVersion(resticVersion string) (err error)

SetResticVersion sets the effective restic version for validation and to determine how to format flags. Note that flags filtering happens later inside resticWrapper and is not necessary inside the profile.

func (*Profile) SetRootPath

func (p *Profile) SetRootPath(rootPath string)

SetRootPath changes the path of all the relative paths and files in the configuration

func (*Profile) SetTag added in v0.17.0

func (p *Profile) SetTag(tags ...string)

SetTag will replace any tag value from a boolean to the tags

type ProfileInfo added in v0.15.0

type ProfileInfo interface {
	// PropertySet contains properties shared across sections
	PropertySet
	// Sections returns a list of all known section names
	Sections() []string
	// SectionInfo returns information for a named section
	SectionInfo(name string) SectionInfo
}

ProfileInfo provides structural information on profiles and can be used for specification and validation

func NewProfileInfo added in v0.15.0

func NewProfileInfo(withDefaultOptions bool) ProfileInfo

NewProfileInfo returns structural information on the "profile" config section

func NewProfileInfoForRestic added in v0.21.0

func NewProfileInfoForRestic(resticVersion string, withDefaultOptions bool) ProfileInfo

NewProfileInfoForRestic returns versioned structural information on the "profile" config section for the specified semantic resticVersion. withDefaultOptions toggles whether to include default command options with every single section.

type ProfileTemplateData added in v0.10.0

type ProfileTemplateData struct {
	Name string
}

ProfileTemplateData contains profile data

type PropertyInfo added in v0.21.0

type PropertyInfo interface {
	// Named provides Name and Description of the property
	Named
	// IsOption indicates whether the property is a restic command option
	IsOption() bool
	// Option provides the restic option when IsOption is true
	Option() restic.Option
	// IsRequired indicates whether the property must be present in its PropertySet
	IsRequired() bool
	// IsDeprecated indicates whether the property is discontinued
	IsDeprecated() bool
	// IsSingle indicates that the property can be defined only once.
	IsSingle() bool
	// IsSinglePropertySet indicates that a nested PropertySet can be defined only once (is implied with IsSingle).
	IsSinglePropertySet() bool
	// IsMultiType indicates that more than one of CanBeString, CanBeNumeric, CanBeBool & CanBePropertySet returns true
	IsMultiType() bool
	// IsAnyType indicates that all of CanBeString, CanBeNumeric & CanBeBool return true
	IsAnyType() bool
	// CanBeString indicates that the value can a string value
	CanBeString() bool
	// CanBeNumeric indicates that the value can be numeric
	CanBeNumeric() bool
	// CanBeBool indicates that the value can be boolean true or false
	CanBeBool() bool
	// CanBeNil indicates that the value can be set to null (or undefined)
	CanBeNil() bool
	// CanBePropertySet indicates that the property can be a property set (= nested object or array of objects)
	CanBePropertySet() bool
	// PropertySet returns the property set that this property can be filled with (possibly nil)
	PropertySet() NamedPropertySet
	// Format may provide a string describing the expected input format (e.g. time, duration, base64, etc.).
	Format() string
	// ValidationPattern may provide a regular expression to validate the value
	ValidationPattern() string
	// MustBeInteger indicates that a numeric value must be integer
	MustBeInteger() bool
	// DefaultValue returns the default value(s)
	DefaultValue() []string
	// ExampleValues may provide example values
	ExampleValues() []string
	// EnumValues may provide a list of all possible values
	EnumValues() []string
	// NumericRange may provide a valid range for numbers
	NumericRange() NumericRange
}

PropertyInfo provides details on an individual property

type PropertySet added in v0.21.0

type PropertySet interface {
	// TypeName returns the name of the type that declared the property set. The name may be empty.
	TypeName() string
	// IsClosed indicates that a property set supports only know properties (as opposed to a non-closed set that may hold arbitrary properties)
	IsClosed() bool
	// IsAllOptions indicates that all properties in this set return IsOption true
	IsAllOptions() bool
	// Properties provides the names of all known config properties in the set
	Properties() []string
	// PropertyInfo provides information on a named property
	PropertyInfo(name string) PropertyInfo
	// OtherPropertyInfo provides information on arbitrary properties in a set where IsClosed is false. Is nil if any arbitrary property is supported.
	OtherPropertyInfo() PropertyInfo
}

PropertySet provides structural information on a set of properties

type RetentionSection

type RetentionSection struct {
	ScheduleBaseSection `mapstructure:",squash" deprecated:"0.11.0"`
	OtherFlagsSection   `mapstructure:",squash"`
	BeforeBackup        maybe.Bool `mapstructure:"before-backup" description:"Apply retention before starting the backup command"`
	AfterBackup         maybe.Bool `` /* 198-byte string literal not displayed */
}

RetentionSection contains the specific configuration to the 'forget' command when running as part of a backup

func (*RetentionSection) IsEmpty added in v0.17.0

func (r *RetentionSection) IsEmpty() bool

type RunShellCommands added in v0.19.0

type RunShellCommands interface {
	GetRunShellCommands() *RunShellCommandsSection
}

RunShellCommands provides access to shell command hooks inside a section

type RunShellCommandsSection added in v0.19.0

type RunShellCommandsSection struct {
	RunBefore    []string `mapstructure:"run-before" description:"Run shell command(s) before a restic command"`
	RunAfter     []string `mapstructure:"run-after" description:"Run shell command(s) after a successful restic command"`
	RunAfterFail []string `mapstructure:"run-after-fail" description:"Run shell command(s) after failed restic or shell commands"`
	RunFinally   []string `mapstructure:"run-finally" description:"Run shell command(s) always, after all other commands"`
}

RunShellCommandsSection is used to define shell commands that run before or after restic commands

func (*RunShellCommandsSection) GetRunShellCommands added in v0.19.0

func (r *RunShellCommandsSection) GetRunShellCommands() *RunShellCommandsSection

type Schedulable added in v0.27.0

type Schedulable interface {
	// Schedules returns a command to schedule map
	Schedules() map[string]*Schedule
}

Schedulable may be implemented by sections that can provide command schedules (= groups and profiles)

type Schedule added in v0.16.1

type Schedule struct {
	ScheduleConfig
	ConfigFile  string            `show:"noshow"`
	Environment []string          `show:"noshow"`
	Flags       map[string]string `show:"noshow"`
}

Schedule is the configuration used in profiles and groups for passing the user config to the scheduler system.

func NewDefaultSchedule added in v0.27.0

func NewDefaultSchedule(config *Config, origin ScheduleConfigOrigin, schedules ...string) *Schedule

NewDefaultSchedule creates a new Schedule for the specified ScheduleConfigOrigin that is initialized with defaults

func NewSchedule added in v0.27.0

func NewSchedule(config *Config, sc *ScheduleConfig) *Schedule

NewSchedule creates a new Schedule for the specified Config and ScheduleConfig

func (*Schedule) Compare added in v0.27.0

func (s *Schedule) Compare(other *Schedule) (c int)

func (*Schedule) GetFlag added in v0.27.0

func (s *Schedule) GetFlag(name string) (string, bool)

func (*Schedule) GetId added in v0.27.0

func (s *Schedule) GetId() string

func (*Schedule) GetLockMode added in v0.27.0

func (s *Schedule) GetLockMode() ScheduleLockMode

func (*Schedule) GetLockWait added in v0.27.0

func (s *Schedule) GetLockWait() time.Duration

func (*Schedule) SetFlag added in v0.27.0

func (s *Schedule) SetFlag(name, value string)

type ScheduleBaseConfig added in v0.27.0

type ScheduleBaseConfig struct {
	Permission              string         `` /* 238-byte string literal not displayed */
	Log                     string         `` /* 264-byte string literal not displayed */
	CommandOutput           string         `` /* 397-byte string literal not displayed */
	Priority                string         `` /* 131-byte string literal not displayed */
	LockMode                string         `` /* 215-byte string literal not displayed */
	LockWait                maybe.Duration `` /* 149-byte string literal not displayed */
	EnvCapture              []string       `` /* 367-byte string literal not displayed */
	IgnoreOnBattery         maybe.Bool     `mapstructure:"ignore-on-battery" default:"false" description:"Don't start this schedule when running on battery"`
	IgnoreOnBatteryLessThan int            `` /* 193-byte string literal not displayed */
	AfterNetworkOnline      maybe.Bool     `` /* 130-byte string literal not displayed */
	SystemdDropInFiles      []string       `` /* 185-byte string literal not displayed */
}

ScheduleBaseConfig is the base user configuration that could be shared across all schedules.

type ScheduleBaseSection added in v0.18.0

type ScheduleBaseSection struct {
	Schedule                        any            `` /* 275-byte string literal not displayed */
	SchedulePermission              string         `` /* 261-byte string literal not displayed */
	ScheduleLog                     string         `` /* 212-byte string literal not displayed */
	SchedulePriority                string         `` /* 154-byte string literal not displayed */
	ScheduleLockMode                string         `` /* 238-byte string literal not displayed */
	ScheduleLockWait                maybe.Duration `` /* 172-byte string literal not displayed */
	ScheduleEnvCapture              []string       `` /* 390-byte string literal not displayed */
	ScheduleIgnoreOnBattery         maybe.Bool     `` /* 135-byte string literal not displayed */
	ScheduleIgnoreOnBatteryLessThan int            `` /* 216-byte string literal not displayed */
	ScheduleAfterNetworkOnline      maybe.Bool     `` /* 153-byte string literal not displayed */
	// contains filtered or unexported fields
}

ScheduleBaseSection contains the parameters for scheduling a command (backup, check, forget, etc.)

func (*ScheduleBaseSection) HasSchedule added in v0.27.0

func (s *ScheduleBaseSection) HasSchedule() bool

type ScheduleConfig added in v0.9.0

type ScheduleConfig struct {
	Schedules          []string `` /* 234-byte string literal not displayed */
	ScheduleBaseConfig `mapstructure:",squash"`
	// contains filtered or unexported fields
}

ScheduleConfig is the user configuration of a specific schedule bound to a command in a profile or group.

func NewDefaultScheduleConfig added in v0.27.0

func NewDefaultScheduleConfig(config *Config, origin ScheduleConfigOrigin, schedules ...string) (s *ScheduleConfig)

NewDefaultScheduleConfig returns a new schedule configuration that is initialized with defaults

func (*ScheduleConfig) HasSchedules added in v0.27.0

func (s *ScheduleConfig) HasSchedules() bool

HasSchedules returns true if the normalized list of schedules is not empty. The func is nil tolerant and returns false for config.Schedule(nil).HasSchedules()

func (*ScheduleConfig) ScheduleOrigin added in v0.27.0

func (s *ScheduleConfig) ScheduleOrigin() ScheduleConfigOrigin

type ScheduleConfigOrigin added in v0.27.0

type ScheduleConfigOrigin struct {
	Type          ScheduleOriginType
	Name, Command string
}

func ScheduleOrigin added in v0.27.0

func ScheduleOrigin(name, command string, kind ...ScheduleOriginType) (s ScheduleConfigOrigin)

ScheduleOrigin returns a origin for the specified name command and optional type (defaulting to ScheduleOriginProfile)

func (ScheduleConfigOrigin) Compare added in v0.27.0

func (o ScheduleConfigOrigin) Compare(other ScheduleConfigOrigin) (c int)

func (ScheduleConfigOrigin) String added in v0.27.0

func (o ScheduleConfigOrigin) String() string

type ScheduleLockMode added in v0.14.0

type ScheduleLockMode int8

type ScheduleOriginType added in v0.27.0

type ScheduleOriginType int
const (
	ScheduleOriginProfile ScheduleOriginType = iota
	ScheduleOriginGroup
)

type ScheduleTemplateData added in v0.16.1

type ScheduleTemplateData struct {
	Name string
}

ScheduleTemplateData contains schedule data

type SectionInfo added in v0.21.0

type SectionInfo interface {
	// Named provides Name and Description of the section
	Named
	// PropertySet contains properties for this section
	PropertySet
	// IsCommandSection indicates whether the section configures a restic command
	IsCommandSection() bool
	// Command provides the restic command for the section when this is a command section
	Command() restic.CommandIf
}

SectionInfo provides structural information on a particular profile section

type SectionWithScheduleAndMonitoring added in v0.18.0

type SectionWithScheduleAndMonitoring struct {
	ScheduleBaseSection    `mapstructure:",squash"`
	SendMonitoringSections `mapstructure:",squash"`
	OtherFlagsSection      `mapstructure:",squash"`
}

SectionWithScheduleAndMonitoring is a section containing schedule, shell command hooks and monitoring (all the other parameters being for restic)

func (*SectionWithScheduleAndMonitoring) IsEmpty added in v0.18.0

type SendMonitoringHeader added in v0.18.0

type SendMonitoringHeader struct {
	Name  string            `` /* 171-byte string literal not displayed */
	Value ConfidentialValue `` /* 192-byte string literal not displayed */
}

SendMonitoringHeader is used to send HTTP headers

type SendMonitoringSection added in v0.18.0

type SendMonitoringSection struct {
	Method       string                 `` /* 128-byte string literal not displayed */
	URL          ConfidentialValue      `mapstructure:"url" format:"uri" description:"URL of the target to send to"`
	Headers      []SendMonitoringHeader `mapstructure:"headers" description:"Additional HTTP headers to send with the request"`
	Body         string                 `mapstructure:"body" description:"Request body, overrides \"body-template\""`
	BodyTemplate string                 `` /* 193-byte string literal not displayed */
	SkipTLS      bool                   `` /* 131-byte string literal not displayed */
}

SendMonitoringSection is used to send monitoring information to third party software

type SendMonitoringSections added in v0.18.0

type SendMonitoringSections struct {
	SendBefore    []SendMonitoringSection `mapstructure:"send-before" description:"Send HTTP request(s) before a restic command"`
	SendAfter     []SendMonitoringSection `mapstructure:"send-after" description:"Send HTTP request(s) after a successful restic command"`
	SendAfterFail []SendMonitoringSection `mapstructure:"send-after-fail" description:"Send HTTP request(s) after failed restic or shell commands"`
	SendFinally   []SendMonitoringSection `mapstructure:"send-finally" description:"Send HTTP request(s) always, after all other commands"`
}

SendMonitoringSections is a group of target to send monitoring information

func (*SendMonitoringSections) GetSendMonitoring added in v0.19.0

func (s *SendMonitoringSections) GetSendMonitoring() *SendMonitoringSections

type StreamErrorSection added in v0.17.0

type StreamErrorSection struct {
	Pattern    string `` /* 138-byte string literal not displayed */
	MinMatches int    `` /* 147-byte string literal not displayed */
	MaxRuns    int    `mapstructure:"max-runs" range:"[0:]" description:"Maximum amount of times that \"run\" is started ; 0 for no limit"`
	Run        string `mapstructure:"run" description:"The shell command to run when the pattern matches"`
}

type TemplateData added in v0.10.0

type TemplateData struct {
	templates.DefaultData
	Profile   ProfileTemplateData
	Schedule  ScheduleTemplateData
	ConfigDir string
}

TemplateData contain the variables fed to a config template

type TemplateInfoData added in v0.21.0

type TemplateInfoData struct {
	templates.DefaultData
	Global, Group       PropertySet
	Profile             ProfileInfo
	KnownResticVersions []string
}

TemplateInfoData is used as data for go templates that render config references

func NewTemplateInfoData added in v0.21.0

func NewTemplateInfoData(resticVersion string) *TemplateInfoData

NewTemplateInfoData returns template data to render references for the specified resticVersion

func (*TemplateInfoData) GetFuncs added in v0.21.0

func (t *TemplateInfoData) GetFuncs() map[string]any

GetFuncs returns a map of helpers to be used as methods when rendering templates

func (*TemplateInfoData) NestedSections added in v0.27.0

func (t *TemplateInfoData) NestedSections() []SectionInfo

NestedSections lists SectionInfo of all nested sections that may be used inside the configuration

func (*TemplateInfoData) ProfileSections added in v0.21.0

func (t *TemplateInfoData) ProfileSections() []SectionInfo

ProfileSections is a helper method for templates to list SectionInfo in ProfileInfo

type Version added in v0.16.1

type Version int
const (
	VersionUnknown Version = iota
	Version01
	Version02
	VersionMax = Version02
)

func ParseVersion added in v0.16.1

func ParseVersion(raw string) Version

ParseVersion return the version number, if invalid the default version is Version01

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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