Documentation
¶
Index ¶
- Constants
- 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 ¶
const ( // prometheus Namespace = "baas" Subsystem = "backup_restic" // general 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 BackupStats ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (b *BackupStats) ToJson() []byte
func (*BackupStats) ToProm ¶ added in v0.2.0
func (b *BackupStats) ToProm() []prometheus.Collector
type Command ¶ added in v0.2.0
Command can handle a given command.
func NewCommand ¶ added in v0.2.0
NewCommand returns a new command
func (*Command) Configure ¶ added in v0.2.0
func (c *Command) Configure()
Configure will setup the command object. Mainly set the env vars and wire the right stdins/outs.
func (*Command) Run ¶ added in v0.2.0
func (c *Command) Run()
Run will run the currently configured command and wait for its completion.
type CommandOptions ¶ added in v0.2.0
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 ¶ added in v0.3.0
Flags stores arguments to pass to `restic` and can return them as array, see ApplyToCommand().
func Combine ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (p *PromMetrics) ToProm() []prometheus.Collector
type PrometheusProvider ¶ added in v0.2.0
type PrometheusProvider interface {
ToProm() []prometheus.Collector
}
type RawMetrics ¶ added in v0.2.0
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 ¶ added in v0.2.0
Backup backup to the repository. It will loop through all subfolders of backupdir and trigger a snapshot for each of them.
func (*Restic) Init ¶ added in v0.2.0
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 ¶ added in v0.2.0
LastSnapshots only returns the latests snapshots for a given set of tags.
func (*Restic) Restore ¶ added in v0.2.0
func (r *Restic) Restore(snapshotID string, options RestoreOptions, tags ArrayOpts) error
Restore triggers a restore of a snapshot
func (*Restic) Snapshots ¶ added in v0.2.0
Snapshots lists all the snapshots from the repository and saves them in the restic instance for further use.
func (*Restic) StdinBackup ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.3
type RestoreStats struct { RestoreLocation string `json:"restore_location,omitempty"` SnapshotID string `json:"snapshot_ID,omitempty"` RestoredFiles []string `json:"restored_files,omitempty"` }
func (*RestoreStats) ToJson ¶ added in v0.2.3
func (r *RestoreStats) ToJson() []byte
type RestoreType ¶ added in v0.2.0
type RestoreType string
RestoreType defines the type for a restore.
const ( FolderRestore RestoreType = "folder" S3Restore RestoreType = "s3" )
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 ¶ added in v0.2.0
type StatsHandler interface { SendPrometheus(PrometheusProvider) error SendWebhook(WebhookProvider) error }
type WebhookProvider ¶ added in v0.2.0
type WebhookProvider interface {
ToJson() []byte
}