Documentation ¶
Index ¶
- type ArrayOpts
- type BackupStats
- type Command
- type CommandOptions
- type Flags
- type Lock
- type PromMetrics
- type PrometheusProvider
- type RawMetrics
- type Restic
- func (r *Restic) Archive(restoreFilter string, verifyRestore bool, tags ArrayOpts) error
- func (r *Restic) Backup(backupDir string, tags ArrayOpts) error
- func (r *Restic) Check() error
- func (r *Restic) Init() error
- func (r *Restic) LastSnapshots(tags ArrayOpts) error
- func (r *Restic) Prune(tags ArrayOpts) error
- func (r *Restic) Restore(snapshotID string, options RestoreOptions, tags ArrayOpts) error
- func (r *Restic) Snapshots(tags ArrayOpts) error
- func (r *Restic) StdinBackup(data *kubernetes.ExecData, filename, fileExt string, tags ArrayOpts) error
- func (r *Restic) Unlock(all bool) error
- func (r *Restic) Wait() error
- type RestoreOptions
- type RestoreStats
- type RestoreType
- type S3Bucket
- type Snapshot
- type StatsHandler
- type WebhookProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupStats ¶
type BackupStats struct { Name string `json:"name,omitempty"` BucketName string `json:"bucket_name,omitempty"` BackupMetrics *RawMetrics `json:"backup_metrics,omitempty"` Snapshots []Snapshot `json:"snapshots,omitempty"` }
func (*BackupStats) ToJSON ¶
func (b *BackupStats) ToJSON() []byte
func (*BackupStats) ToProm ¶
func (b *BackupStats) ToProm() []prometheus.Collector
type Command ¶
Command can handle a given command.
func NewCommand ¶
NewCommand returns a new command
func (*Command) Configure ¶
func (c *Command) Configure()
Configure will setup the command object. Mainly set the env vars and wire the right stdins/outs.
func (*Command) Run ¶
func (c *Command) Run()
Run will run the currently configured command and wait for its completion.
type CommandOptions ¶
type CommandOptions struct { Path string // path where the command is to be executed StdIn io.Reader // set the StdIn for the command StdOut io.Writer // set the StdOut for the command StdErr io.Writer // set StdErr for the command Args []string }
CommandOptions contains options for the command struct.
type Flags ¶
Flags stores arguments to pass to `restic` and can return them as array, see ApplyToCommand().
func Combine ¶
Combine returns a new Flags instance that contains the flags and their values of both, the given Flags and the Flags instance
func (Flags) AddFlag ¶
AddFlag appends the given values to the existing flag (identified by key) if it exists or appends it and it's values to the end of the list of globalFlags otherwise.
func (Flags) ApplyToCommand ¶
ApplyToCommand applies the globalFlags to the given command and it's arguments, such that `newArgs = [command, globalFlags..., commandArgs...]`, in order the returning array to be passed to the `restic` process.
type PromMetrics ¶
type PromMetrics struct { Errors *prometheus.GaugeVec AvailableSnapshots prometheus.Gauge NewFiles *prometheus.GaugeVec ChangedFiles *prometheus.GaugeVec UnmodifiedFiles *prometheus.GaugeVec NewDirs *prometheus.GaugeVec ChangedDirs *prometheus.GaugeVec UnmodifiedDirs *prometheus.GaugeVec DataTransferred *prometheus.GaugeVec }
func (*PromMetrics) ToProm ¶
func (p *PromMetrics) ToProm() []prometheus.Collector
type PrometheusProvider ¶
type PrometheusProvider interface {
ToProm() []prometheus.Collector
}
type RawMetrics ¶
type RawMetrics struct { BackupStartTimestamp float64 `json:"backup_start_timestamp"` BackupEndTimestamp float64 `json:"backup_end_timestamp"` Errors float64 `json:"errors"` NewFiles float64 `json:"new_files"` ChangedFiles float64 `json:"changed_files"` UnmodifiedFiles float64 `json:"unmodified_files"` NewDirs float64 `json:"new_dirs"` ChangedDirs float64 `json:"changed_dirs"` UnmodifiedDirs float64 `json:"unmodified_dirs"` DataTransferred float64 `json:"data_transferred"` MountedPVCs []string `json:"mounted_PVCs"` Folder string ID string `json:"id"` // contains filtered or unexported fields }
RawMetrics contains the raw metrics that can be obtained at the end of a backup. Webhookdata and prometheus statistics are derived from it.
type Restic ¶
type Restic struct {
// contains filtered or unexported fields
}
func (*Restic) Backup ¶
Backup backup to the repository. It will loop through all subfolders of backupdir and trigger a snapshot for each of them.
func (*Restic) Init ¶
Init initialises a repository, checks if the repositor exists and will initialise it if not. It's save to call this every time.
func (*Restic) LastSnapshots ¶
LastSnapshots only returns the latests snapshots for a given set of tags.
func (*Restic) Restore ¶
func (r *Restic) Restore(snapshotID string, options RestoreOptions, tags ArrayOpts) error
Restore triggers a restore of a snapshot
func (*Restic) Snapshots ¶
Snapshots lists all the snapshots from the repository and saves them in the restic instance for further use.
func (*Restic) StdinBackup ¶
func (r *Restic) StdinBackup(data *kubernetes.ExecData, filename, fileExt string, tags ArrayOpts) error
StdinBackup create a snapshot with the data contained in the given reader.
type RestoreOptions ¶
type RestoreOptions struct { RestoreType RestoreType RestoreDir string RestoreFilter string Verify bool S3Destination S3Bucket }
RestoreOptions holds options for a single restore, like type and destination.
type RestoreStats ¶
type RestoreStats struct { RestoreLocation string `json:"restore_location,omitempty"` SnapshotID string `json:"snapshot_ID,omitempty"` RestoredFiles []string `json:"restored_files,omitempty"` }
func (*RestoreStats) ToJSON ¶
func (r *RestoreStats) ToJSON() []byte
type RestoreType ¶
type RestoreType string
RestoreType defines the type for a restore.
const ( // FolderRestore indicates that a restore to a folder should be performed. FolderRestore RestoreType = cfg.RestoreTypeFolder // S3Restore indicates that a restore to a S3 endpoint should be performed. S3Restore RestoreType = cfg.RestoreTypeS3 )
type Snapshot ¶
type Snapshot struct { ID string `json:"id"` Time time.Time `json:"time"` Tree string `json:"tree"` Paths []string `json:"paths"` Hostname string `json:"hostname"` Username string `json:"username"` UID int `json:"uid"` Gid int `json:"gid"` Tags []string `json:"tags"` }
Snapshot models a restic a single snapshot from the snapshots --json subcommand.
type StatsHandler ¶
type StatsHandler interface { SendPrometheus(PrometheusProvider) error SendWebhook(WebhookProvider) error }
type WebhookProvider ¶
type WebhookProvider interface {
ToJSON() []byte
}