restic

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvToPropagate = []string{

	"PATH", "HOME", "XDG_CACHE_HOME", "XDG_CONFIG_HOME", "XDG_DATA_HOME",

	"APPDATA", "LOCALAPPDATA",
}
View Source
var ErrBackupFailed = errors.New("backup failed")
View Source
var ErrPartialBackup = errors.New("incomplete backup")

Functions

func ValidateSnapshotId

func ValidateSnapshotId(id string) error

Types

type BackupOption

type BackupOption func(opts *BackupOpts)

func WithBackupExcludes

func WithBackupExcludes(excludes ...string) BackupOption

func WithBackupParent

func WithBackupParent(parent string) BackupOption

func WithBackupPaths

func WithBackupPaths(paths ...string) BackupOption

func WithBackupTags

func WithBackupTags(tags ...string) BackupOption

type BackupOpts

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

type BackupProgressEntry

type BackupProgressEntry struct {
	// Common fields
	MessageType string `json:"message_type"` // "summary" or "status"

	// Summary fields
	FilesNew            int     `json:"files_new"`
	FilesChanged        int     `json:"files_changed"`
	FilesUnmodified     int     `json:"files_unmodified"`
	DirsNew             int     `json:"dirs_new"`
	DirsChanged         int     `json:"dirs_changed"`
	DirsUnmodified      int     `json:"dirs_unmodified"`
	DataBlobs           int     `json:"data_blobs"`
	TreeBlobs           int     `json:"tree_blobs"`
	DataAdded           int     `json:"data_added"`
	TotalFilesProcessed int     `json:"total_files_processed"`
	TotalBytesProcessed int     `json:"total_bytes_processed"`
	TotalDuration       float64 `json:"total_duration"`
	SnapshotId          string  `json:"snapshot_id"`

	// Status fields
	PercentDone  float64  `json:"percent_done"`
	TotalFiles   int      `json:"total_files"`
	FilesDone    int      `json:"files_done"`
	TotalBytes   int      `json:"total_bytes"`
	BytesDone    int      `json:"bytes_done"`
	CurrentFiles []string `json:"current_files"`
}

func (*BackupProgressEntry) Validate

func (b *BackupProgressEntry) Validate() error

type CmdError

type CmdError struct {
	Command string
	Err     error
	Output  string
}

func (*CmdError) Error

func (e *CmdError) Error() string

func (*CmdError) Is

func (e *CmdError) Is(target error) bool

func (*CmdError) Unwrap

func (e *CmdError) Unwrap() error

type ForgetResult

type ForgetResult struct {
	Keep   []Snapshot `json:"keep"`
	Remove []Snapshot `json:"remove"`
}

func (*ForgetResult) Validate

func (r *ForgetResult) Validate() error

type GenericOption

type GenericOption func(opts *GenericOpts)

func WithEnv

func WithEnv(env ...string) GenericOption

func WithFlags

func WithFlags(flags ...string) GenericOption

func WithPropagatedEnvVars

func WithPropagatedEnvVars(extras ...string) GenericOption

func WithTags

func WithTags(tags ...string) GenericOption

type GenericOpts

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

type LsEntry

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

func (*LsEntry) ToProto

func (e *LsEntry) ToProto() *v1.LsEntry

type Repo

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

func NewRepo

func NewRepo(resticBin string, repo *v1.Repo, opts ...GenericOption) *Repo

NewRepo instantiates a new repository. TODO: should not accept a v1.Repo, should instead be configured by parameters.

func (*Repo) Backup

func (r *Repo) Backup(ctx context.Context, progressCallback func(*BackupProgressEntry), opts ...BackupOption) (*BackupProgressEntry, error)

func (*Repo) Forget

func (r *Repo) Forget(ctx context.Context, policy *RetentionPolicy, opts ...GenericOption) (*ForgetResult, error)

func (*Repo) Init

func (r *Repo) Init(ctx context.Context) error

func (*Repo) ListDirectory

func (r *Repo) ListDirectory(ctx context.Context, snapshot string, path string, opts ...GenericOption) (*Snapshot, []*LsEntry, error)

func (*Repo) Prune

func (r *Repo) Prune(ctx context.Context, pruneOutput io.Writer, opts ...GenericOption) error

func (*Repo) Restore

func (r *Repo) Restore(ctx context.Context, snapshot string, callback func(*RestoreProgressEntry), opts ...GenericOption) (*RestoreProgressEntry, error)

func (*Repo) Snapshots

func (r *Repo) Snapshots(ctx context.Context, opts ...GenericOption) ([]*Snapshot, error)

func (*Repo) Stats added in v0.8.0

func (r *Repo) Stats(ctx context.Context, opts ...GenericOption) (*RepoStats, error)

func (*Repo) Unlock

func (r *Repo) Unlock(ctx context.Context, opts ...GenericOption) error

type RepoStats added in v0.8.0

type RepoStats struct {
	TotalSize              int64   `json:"total_size"`
	TotalUncompressedSize  int64   `json:"total_uncompressed_size"`
	CompressionRatio       float64 `json:"compression_ratio"`
	CompressionProgress    int64   `json:"compression_progress"`
	CompressionSpaceSaving float64 `json:"compression_space_saving"`
	TotalBlobCount         int64   `json:"total_blob_count"`
	SnapshotsCount         int64   `json:"snapshots_count"`
}

type RestoreProgressEntry

type RestoreProgressEntry struct {
	MessageType    string  `json:"message_type"` // "summary" or "status"
	SecondsElapsed float64 `json:"seconds_elapsed"`
	TotalBytes     int64   `json:"total_bytes"`
	BytesRestored  int64   `json:"bytes_restored"`
	TotalFiles     int64   `json:"total_files"`
	FilesRestored  int64   `json:"files_restored"`
	PercentDone    float64 `json:"percent_done"`
}

func (*RestoreProgressEntry) Validate

func (e *RestoreProgressEntry) Validate() error

type RetentionPolicy

type RetentionPolicy struct {
	KeepLastN          int    // keep the last n snapshots.
	KeepHourly         int    // keep the last n hourly snapshots.
	KeepDaily          int    // keep the last n daily snapshots.
	KeepWeekly         int    // keep the last n weekly snapshots.
	KeepMonthly        int    // keep the last n monthly snapshots.
	KeepYearly         int    // keep the last n yearly snapshots.
	KeepWithinDuration string // keep snapshots within a duration e.g. 1y2m3d4h5m6s
}

type Snapshot

type Snapshot struct {
	Id       string   `json:"id"`
	Time     string   `json:"time"`
	Tree     string   `json:"tree"`
	Paths    []string `json:"paths"`
	Hostname string   `json:"hostname"`
	Username string   `json:"username"`
	Tags     []string `json:"tags"`
	Parent   string   `json:"parent"`
	// contains filtered or unexported fields
}

func (*Snapshot) UnixTimeMs

func (s *Snapshot) UnixTimeMs() int64

func (*Snapshot) Validate

func (s *Snapshot) Validate() error

Jump to

Keyboard shortcuts

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