restic

package
v0.0.10-travis Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//prometheus
	Namespace = "baas"
	Subsystem = "backup_restic"

	Hostname = "HOSTNAME"

	BackupDirEnv = "BACKUP_DIR"

	//Restore
	RestoreS3EndpointEnv     = "RESTORE_S3ENDPOINT"
	RestoreS3AccessKeyIDEnv  = "RESTORE_ACCESSKEYID"
	RestoreS3SecretAccessKey = "RESTORE_SECRETACCESSKEY"
	RestoreDirEnv            = "RESTORE_DIR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupStruct

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

BackupStruct holds the state of a backup command.

func (*BackupStruct) Backup

func (b *BackupStruct) Backup()

Backup executes a backup command.

func (*BackupStruct) GetError

func (g *BackupStruct) GetError() error

GetError returns if there was an error

func (*BackupStruct) GetStdErrOut

func (g *BackupStruct) GetStdErrOut() []string

GetStdErrOut returns the complete StdErr of the command

func (*BackupStruct) GetStdOut

func (g *BackupStruct) GetStdOut() []string

GetStdOut returns the complete output of the command

func (*BackupStruct) GetWebhookData

func (b *BackupStruct) GetWebhookData() []output.JsonMarshaller

GetWebhookData a slice of objects that should be sent to the webhook endpoint.

func (*BackupStruct) StdinBackup

func (b *BackupStruct) StdinBackup(backupCommand, pod, container, namespace, fileExt string)

StdinBackup triggers a backup that attaches itself to the given container on a Kubernetes cluster.

func (*BackupStruct) ToProm

func (b *BackupStruct) ToProm() []prometheus.Collector

ToProm resturns a slice of prometheus collectors that should get sent to the prom push gateway.

type CheckStruct

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

CheckStruct holds the state of the check command.

func (*CheckStruct) Check

func (c *CheckStruct) Check()

Check runs the check command.

func (*CheckStruct) GetError

func (g *CheckStruct) GetError() error

GetError returns if there was an error

func (*CheckStruct) GetStdErrOut

func (g *CheckStruct) GetStdErrOut() []string

GetStdErrOut returns the complete StdErr of the command

func (*CheckStruct) GetStdOut

func (g *CheckStruct) GetStdOut() []string

GetStdOut returns the complete output of the command

func (*CheckStruct) GetWebhookData

func (g *CheckStruct) GetWebhookData() []output.JsonMarshaller

GetWebhookData returns all objects that should get marshalled to json and sent to the webhook endpoint. Returns nil by default.

func (*CheckStruct) ToProm

func (g *CheckStruct) ToProm() []prometheus.Collector

ToProm returns a list of prometheus collectors that should get pushed to the prometheus push gateway.

type Initrepo

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

Initrepo checks if there's a repository and initializes it.

func (*Initrepo) GetError

func (g *Initrepo) GetError() error

GetError returns if there was an error

func (*Initrepo) GetStdErrOut

func (g *Initrepo) GetStdErrOut() []string

GetStdErrOut returns the complete StdErr of the command

func (*Initrepo) GetStdOut

func (g *Initrepo) GetStdOut() []string

GetStdOut returns the complete output of the command

func (*Initrepo) GetWebhookData

func (g *Initrepo) GetWebhookData() []output.JsonMarshaller

GetWebhookData returns all objects that should get marshalled to json and sent to the webhook endpoint. Returns nil by default.

func (*Initrepo) InitRepository

func (i *Initrepo) InitRepository(s3Client *s3.Client)

InitRepository checks if there's a repository and initializes it. It expects a working

func (*Initrepo) ToProm

func (g *Initrepo) ToProm() []prometheus.Collector

ToProm returns a list of prometheus collectors that should get pushed to the prometheus push gateway.

type ListSnapshotsStruct

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

ListSnapshotsStruct holds the state of the listsnapshots command.

func (*ListSnapshotsStruct) GetError

func (g *ListSnapshotsStruct) GetError() error

GetError returns if there was an error

func (*ListSnapshotsStruct) GetStdErrOut

func (g *ListSnapshotsStruct) GetStdErrOut() []string

GetStdErrOut returns the complete StdErr of the command

func (*ListSnapshotsStruct) GetStdOut

func (g *ListSnapshotsStruct) GetStdOut() []string

GetStdOut returns the complete output of the command

func (*ListSnapshotsStruct) GetWebhookData

func (l *ListSnapshotsStruct) GetWebhookData() []output.JsonMarshaller

GetWebhookData returns a list of snapshots for the webhook.

func (*ListSnapshotsStruct) ListSnapshots

func (l *ListSnapshotsStruct) ListSnapshots(last bool) []Snapshot

ListSnapshots executes the list snapshots command of restic.

func (*ListSnapshotsStruct) ToProm

func (g *ListSnapshotsStruct) ToProm() []prometheus.Collector

ToProm returns a list of prometheus collectors that should get pushed to the prometheus push gateway.

type PruneStruct

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

PruneStruct holds the state of the prune command.

func (*PruneStruct) GetError

func (g *PruneStruct) GetError() error

GetError returns if there was an error

func (*PruneStruct) GetStdErrOut

func (g *PruneStruct) GetStdErrOut() []string

GetStdErrOut returns the complete StdErr of the command

func (*PruneStruct) GetStdOut

func (g *PruneStruct) GetStdOut() []string

GetStdOut returns the complete output of the command

func (*PruneStruct) GetWebhookData

func (g *PruneStruct) GetWebhookData() []output.JsonMarshaller

GetWebhookData returns all objects that should get marshalled to json and sent to the webhook endpoint. Returns nil by default.

func (*PruneStruct) Prune

func (p *PruneStruct) Prune()

func (*PruneStruct) ToProm

func (g *PruneStruct) ToProm() []prometheus.Collector

ToProm returns a list of prometheus collectors that should get pushed to the prometheus push gateway.

type Restic

Restic is an API representation for restic. You can trigger the defined command very easily. Every command stores its own output and errors (if any) which should provice an easy way to handle logging, outputparsing and error handling.

func New

func New(backupDir string) *Restic

New returns a new restic object.

type RestoreStruct

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

RestoreStruct holds the state of the restore command.

func (*RestoreStruct) Archive

func (r *RestoreStruct) Archive(snaps []Snapshot, restoreType, restoreDir, restoreFilter string, verifyRestore bool)

Archive uploads the last version of each snapshot to S3.

func (*RestoreStruct) GetError

func (g *RestoreStruct) GetError() error

GetError returns if there was an error

func (*RestoreStruct) GetStdErrOut

func (g *RestoreStruct) GetStdErrOut() []string

GetStdErrOut returns the complete StdErr of the command

func (*RestoreStruct) GetStdOut

func (g *RestoreStruct) GetStdOut() []string

GetStdOut returns the complete output of the command

func (*RestoreStruct) GetWebhookData

func (r *RestoreStruct) GetWebhookData() []output.JsonMarshaller

GetWebhookData returns a list of restore stats to send to the webhook.

func (*RestoreStruct) Restore

func (r *RestoreStruct) Restore(snapshotID, method string, snaps []Snapshot, restoreDir, restoreFilter string, verifyRestore bool)

Restore takes a snapshotID and a method to create a restore job.

func (*RestoreStruct) ToProm

func (g *RestoreStruct) ToProm() []prometheus.Collector

ToProm returns a list of prometheus collectors that should get pushed to the prometheus push gateway.

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 Stats

type Stats interface {
	GetJson() []byte
	GetProm()
}

Stats is an interface that returns an interface containing the stats that should get pushed via webhook/prom.

type UnlockStruct

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

UnlockStruct holds the state of the unlock command.

func (*UnlockStruct) GetError

func (g *UnlockStruct) GetError() error

GetError returns if there was an error

func (*UnlockStruct) GetStdErrOut

func (g *UnlockStruct) GetStdErrOut() []string

GetStdErrOut returns the complete StdErr of the command

func (*UnlockStruct) GetStdOut

func (g *UnlockStruct) GetStdOut() []string

GetStdOut returns the complete output of the command

func (*UnlockStruct) GetWebhookData

func (g *UnlockStruct) GetWebhookData() []output.JsonMarshaller

GetWebhookData returns all objects that should get marshalled to json and sent to the webhook endpoint. Returns nil by default.

func (*UnlockStruct) ToProm

func (g *UnlockStruct) ToProm() []prometheus.Collector

ToProm returns a list of prometheus collectors that should get pushed to the prometheus push gateway.

func (*UnlockStruct) Unlock

func (u *UnlockStruct) Unlock(all bool)

Unlock removes stale locks. A lock is stale either if the pid isn't found on the current machine or if it's older than 30 min. (According to the restic source code)

type WebhookStats

type WebhookStats struct {
	Name          string     `json: "name"`
	BackupMetrics rawMetrics `json:"backup_metrics"`
	Snapshots     []Snapshot `json:"snapshots"`
}

func (*WebhookStats) ToJson

func (w *WebhookStats) ToJson() []byte

ToJson returns a byteslice which contains the json representation of the object.

Jump to

Keyboard shortcuts

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