resticmanager

package
v0.0.0-...-211164f Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VersionGitCommit string

Functions

func FindProfiles

func FindProfiles(directory string) []string

FindProfiles searches for profile configuration files in a specified location and returns a list of found files.

Types

type AppConfiguration

type AppConfiguration struct {
	Profiles []*ProfileConfiguration
	DryRun   bool
	// contains filtered or unexported fields
}

AppConfiguration encapsulates the global application configuration.

var AppConfig *AppConfiguration

AppConfig is the global, singleton application configuration object.

func LoadAppConfiguration

func LoadAppConfiguration(filename string) *AppConfiguration

LoadAppConfiguration creates and returns a new AppConfiguration populated from a file.

func NewAppConfiguration

func NewAppConfiguration() *AppConfiguration

NewAppConfiguration creates and returns a new, empty AppConfiguration.

func (*AppConfiguration) EmailLogLevel

func (appConfig *AppConfiguration) EmailLogLevel() glog.LogLevel

EmailLogLevel returns the email log level

func (*AppConfiguration) EmailRecipients

func (appConfig *AppConfiguration) EmailRecipients() []string

EmailRecipients returns the email recipient addresses.

func (*AppConfiguration) EmailSender

func (appConfig *AppConfiguration) EmailSender() string

EmailSender returns the email sender address.

func (*AppConfiguration) EmailTemplate

func (appConfig *AppConfiguration) EmailTemplate() string

EmailTemplate returns the email template.

func (*AppConfiguration) EmailThresholds

func (appConfig *AppConfiguration) EmailThresholds() map[glog.LogLevel]int

EmailThresholds returns the email log thresholds

func (*AppConfiguration) Executable

func (appConfig *AppConfiguration) Executable() string

Executable returns the restic executable filename

func (*AppConfiguration) GetProfileDefaults

func (appConfig *AppConfiguration) GetProfileDefaults() map[string]interface{}

GetProfileDefaults returns a map with default profile values

func (*AppConfiguration) Load

func (appConfig *AppConfiguration) Load(filename string)

Load populates an existing AppConfig from a file.

func (*AppConfiguration) LoggingConfig

func (appConfig *AppConfiguration) LoggingConfig() *_LoggingConfig

LoggingConfig returns the application logging configuration.

func (*AppConfiguration) NewMailer

func (appConfig *AppConfiguration) NewMailer() *Mailer

NewMailer returns a new Mailer

func (*AppConfiguration) RawLog

func (appConfig *AppConfiguration) RawLog() string

RawLog returns the optional raw log filename

func (*AppConfiguration) String

func (appConfig *AppConfiguration) String() string

String returns a string representation of the AppConfiguration

func (*AppConfiguration) Tempdir

func (appConfig *AppConfiguration) Tempdir() string

Tempdir returns the restic temporary directory

type ChangeThreshold

type ChangeThreshold struct {
	TotalFiles int
	TotalBytes float64
}

ChangeThreshold encapsulates a set of snapshot diff change thresholds

type MailMessage

type MailMessage struct {
	Sender     string
	Recipients []string
	Subject    string
	// contains filtered or unexported fields
}

MailMessage encapsulates an email message.

func NewMailMessage

func NewMailMessage() *MailMessage

NewMailMessage returns a new MailMessage.

func (*MailMessage) AddContent

func (message *MailMessage) AddContent(content string)

AddContent adds plain content to the message content.

func (*MailMessage) AddRecipients

func (message *MailMessage) AddRecipients(recipients ...string)

AddRecipients adds the specified set of recipients to the message 'To' header.

func (*MailMessage) AddTemplatedContent

func (message *MailMessage) AddTemplatedContent(templateDefinition string, data interface{})

AddTemplatedContent adds templated content to the message.

func (*MailMessage) Content

func (message *MailMessage) Content() string

Content returns the message content.

func (*MailMessage) SetContext

func (message *MailMessage) SetContext(context string)

SetContext sets the message context, from which a message Subject will be derived.

type Mailer

type Mailer struct {
	SMTP _SmtpConfig
}

Mailer provides an interface to sending e-mail

func NewMailer

func NewMailer() *Mailer

NewMailer creates a new Mailer

func (*Mailer) SendMail

func (mailer *Mailer) SendMail(sender string, recipients []string, subject string, content string)

func (*Mailer) SendMessage

func (mailer *Mailer) SendMessage(message *MailMessage)

type ProfileConfiguration

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

ProfileConfiguration encapsulates the configuration of a restic backup profile.

func LoadProfileConfiguration

func LoadProfileConfiguration(filename string) *ProfileConfiguration

LoadProfileConfiguration creates and returns a new ProfileConfiguration populated from a file.

func LoadProfiles

func LoadProfiles(files []string, filter ProfileFilter, defaults map[string]interface{}) []*ProfileConfiguration

LoadProfiles loads the subset of the specified set of profile files that match the specified filter criteria.

func NewProfileConfiguration

func NewProfileConfiguration() *ProfileConfiguration

NewProfileConfiguration creates and returns a new, empty ProfileConfiguration.

func (*ProfileConfiguration) Arguments

func (profile *ProfileConfiguration) Arguments(operation string) []string

Arguments returns the profile arguments (additional arbitrary restic arguments).

func (*ProfileConfiguration) ChangeThresholds

func (profile *ProfileConfiguration) ChangeThresholds() *ChangeThreshold

ChangeThresholds returns the profile snapshot diff change thresholds.

func (*ProfileConfiguration) EmailLogLevel

func (profile *ProfileConfiguration) EmailLogLevel() glog.LogLevel

EmailLogLevel returns the profile email log level.

func (*ProfileConfiguration) EmailRecipients

func (profile *ProfileConfiguration) EmailRecipients() []string

EmailRecipients returns the profile email recipients.

func (*ProfileConfiguration) EmailThresholds

func (profile *ProfileConfiguration) EmailThresholds() map[glog.LogLevel]int

EmailThresholds returns the email log thresholds

func (*ProfileConfiguration) Exclusions

func (profile *ProfileConfiguration) Exclusions() []string

Exclusions returns the profile exclusions.

func (*ProfileConfiguration) File

func (profile *ProfileConfiguration) File() string

File returns the profile file.

func (*ProfileConfiguration) IsActive

func (profile *ProfileConfiguration) IsActive() bool

IsActive returns the profile active state.

func (*ProfileConfiguration) Load

func (profile *ProfileConfiguration) Load(filename string)

Load populates an existing ProfileConfiguration from a file.

func (*ProfileConfiguration) LogFile

func (profile *ProfileConfiguration) LogFile() string

LogFile returns the profile logfile name.

func (*ProfileConfiguration) LogFileAppend

func (profile *ProfileConfiguration) LogFileAppend() bool

LogFileAppend returns the profile log file append mode

func (*ProfileConfiguration) LogFileLevel

func (profile *ProfileConfiguration) LogFileLevel() glog.LogLevel

LogFileLevel returns the profile file log level.

func (*ProfileConfiguration) MatchesFilter

func (profile *ProfileConfiguration) MatchesFilter(filter ProfileFilter) (bool, string)

MatchesFilter returns true if the ProfileConfiguration matches the specified filter criteria.

func (*ProfileConfiguration) Name

func (profile *ProfileConfiguration) Name() string

Name returns the profile name.

func (*ProfileConfiguration) OperationSequence

func (profile *ProfileConfiguration) OperationSequence() []string

OperationSequence returns the profile operation sequence.

func (*ProfileConfiguration) Password

func (profile *ProfileConfiguration) Password() string

Password returns the profile password.

func (*ProfileConfiguration) Repository

func (profile *ProfileConfiguration) Repository() string

Repository returns the profile repository.

func (*ProfileConfiguration) RetentionPolicies

func (profile *ProfileConfiguration) RetentionPolicies() []RetentionPolicy

RetentionPolicies returns the profile retention policies.

func (*ProfileConfiguration) SetDefaults

func (profile *ProfileConfiguration) SetDefaults(defaults map[string]interface{})

SetDefaults populates an existing ProfileConfiguration with defaults from a given map.

func (*ProfileConfiguration) Source

func (profile *ProfileConfiguration) Source() string

Source returns the profile source directory.

func (*ProfileConfiguration) SourceIsPresent

func (profile *ProfileConfiguration) SourceIsPresent() bool

SourceIsPresent returns true if the Profile source directory exists.

func (*ProfileConfiguration) String

func (profile *ProfileConfiguration) String() string

String returns a string representation of the ProfileConfiguration

func (*ProfileConfiguration) Tags

func (profile *ProfileConfiguration) Tags() []string

Tags returns the profile tags.

type ProfileFilter

type ProfileFilter struct {
	OnlyActive bool
	Names      []string
	Tags       []string
}

ProfileFilter encapsulates profile selection criteria.

func NewProfileFilter

func NewProfileFilter() *ProfileFilter

NewProfileFilter creates and returns a new, empty ProfileFilter.

type Restic

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

Restic provides an interface to the restic backup application.

func NewRestic

func NewRestic(appConfig *AppConfiguration) *Restic

NewRestic creates and returns a new Restic object.

func (*Restic) ApplyRetentionPolicy

func (restic *Restic) ApplyRetentionPolicy(profile *ProfileConfiguration) (string, error)

ApplyRetentionPolicy performs a restic forget operation

func (*Restic) Backup

func (restic *Restic) Backup(profile *ProfileConfiguration) (string, error)

Backup performs a restic backup operation

func (*Restic) Check

func (restic *Restic) Check(profile *ProfileConfiguration) (string, error)

Check performs a restic check operation

func (*Restic) Clean

func (restic *Restic) Clean(profile *ProfileConfiguration) (string, error)

Clean performs a restic prune operation

func (*Restic) Diff

func (restic *Restic) Diff(profile *ProfileConfiguration, beforeID string, afterID string) (*SnapshotDiff, error)

Diff retrieves a difference summary between two specified snapshot IDs

func (*Restic) DiffFromIndices

func (restic *Restic) DiffFromIndices(profile *ProfileConfiguration, beforeIndex int, afterIndex int) (*SnapshotDiff, error)

DiffFromIndices retrieves a difference summary between two specified snapshot indices (0 being most recent, 1 being second-most-recent, etc.)

func (*Restic) Initialise

func (restic *Restic) Initialise(profile *ProfileConfiguration) (string, error)

Initialise performs a restic init operation

func (*Restic) Ls

func (restic *Restic) Ls(profile *ProfileConfiguration, snapshot string) (string, error)

Ls performs a restic ls operation

func (*Restic) Raw

func (restic *Restic) Raw(profile *ProfileConfiguration, command string, arguments []string) (string, error)

Raw performs an arbitrary restic operation

func (*Restic) RebuildIndex

func (restic *Restic) RebuildIndex(profile *ProfileConfiguration) (string, error)

RebuildIndex performs a restic rebuild-index operation

func (*Restic) RepoExists

func (restic *Restic) RepoExists(profile *ProfileConfiguration) (bool, error)

RepoExists tests for the existence of repository

func (*Restic) SnapshotIDFromIndex

func (restic *Restic) SnapshotIDFromIndex(profile *ProfileConfiguration, index int) (string, error)

SnapshotIDFromIndex retrieves a snapshot ID from an index, where 0 is the most-recent

func (*Restic) Snapshots

func (restic *Restic) Snapshots(profile *ProfileConfiguration) (string, error)

Snapshots performs a restic snapshots operation

func (*Restic) Unlock

func (restic *Restic) Unlock(profile *ProfileConfiguration) (string, error)

Unlock performs a restic unlock operation

type RetentionPolicy

type RetentionPolicy struct {
	Period string
	Value  int
}

RetentionPolicy encapsulates a repository retention policy

type SnapshotDiff

type SnapshotDiff struct {
	Report       string
	FilesNew     int
	FilesRemoved int
	FilesChanged int
	DirsNew      int
	DirsRemoved  int
	BytesAdded   float64
	BytesRemoved float64
}

SnapshotDiff encapsulates the differences between two snapshots

func NewSnapshotDiff

func NewSnapshotDiff(diffText string) *SnapshotDiff

NewSnapshotDiff creates and returns a new SnapshotDiff object.

Jump to

Keyboard shortcuts

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