restic

package
v0.2.1-beta Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDirectoryARepository

func IsDirectoryARepository(basedir string) bool

IsDirectoryARepository returns true if the given directory contains everything a restic repository contains

func ResticProgramName

func ResticProgramName() string

ResticProgramName returns the expected platform dependend restic program name

Types

type EnvValue

type EnvValue struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type File

type File struct {
	Name  string `json:"name"`
	Type  string `json:"type"`
	Path  string `json:"path"`
	UID   int    `json:"uid,omitempty"`
	Gid   int    `json:"gid,omitempty"`
	Size  int    `json:"size,omitempty"`
	Mode  int    `json:"mode,omitempty"`
	Mtime string `json:"mtime,omitempty"`
	Atime string `json:"atime,omitempty"`
	Ctime string `json:"ctime,omitempty"`
}

contains all the data relating to a restic File

type Location

type Location struct {
	Prefix       string     `json:"prefix"`      // e.g. "b2"
	Path         string     `json:"path"`        // local path or url or bucket name
	Credientials []EnvValue `json:"credentials"` // optional env values
}

Defines a repository location for restic

func (*Location) PathOrBucketName

func (l *Location) PathOrBucketName() string

return plain location path for local repositories, else prepends the prefix

func (*Location) SetEnv

func (l *Location) SetEnv() error

Set env values from credentials

func (*Location) UnsetEnv

func (l *Location) UnsetEnv() error

Unset env values from credentials

type Repository

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

Repository holds all information about a repository

func NewRepository

func NewRepository(location Location, password string, restic *Restic) *Repository

NewRepository creates a new Repository struct

func (*Repository) DumpFile

func (r *Repository) DumpFile(snapshot *Snapshot, file *File, targetPath string) (string, error)

func (*Repository) GetFiles

func (r *Repository) GetFiles(snapshot *Snapshot, path string) ([]*File, error)

func (*Repository) GetSnapshots

func (r *Repository) GetSnapshots() ([]*Snapshot, error)

func (*Repository) RestoreFile

func (r *Repository) RestoreFile(snapshot *Snapshot, file *File, targetPath string) error

type Restic

type Restic struct {
	VersionString string
	Version       string
	// contains filtered or unexported fields
}

Restic holds information about the Restic Binary

func NewRestic

func NewRestic() (restic *Restic, err error)

NewRestic creates a new Restic struct

func NewResticFromPath

func NewResticFromPath(path string) (restic *Restic, err error)

NewResticFromPath creates a new Restic struct from the given file path

func (*Restic) NewRepo

func (r *Restic) NewRepo(location Location, password string) (*Repository, error)

NewRepo creates a new repo instance

func (*Restic) Run

func (r *Restic) Run(command []string) (stdout, stderr string, code int, err error)

Run restic program and return stdout and err, exitCode and error.

func (*Restic) RunRedirected

func (r *Restic) RunRedirected(stdOutFile *os.File, command []string) (stdErr string, code int, err error)

Run restic program and write stdout to the given file. returns stdErr, exitCode and error.

type Snapshot

type Snapshot struct {
	ID       string   `json:"id"`
	ShortID  string   `json:"short_id"`
	Time     string   `json:"time"`
	Paths    []string `json:"paths"`
	Tags     []string `json:"tags"`
	Hostname string   `json:"hostname"`
	Username string   `json:"username"`
}

holds snapshot info

Jump to

Keyboard shortcuts

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