restic

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: GPL-3.0 Imports: 17 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")
View Source
var ErrRestoreFailed = errors.New("restore failed")

Functions

func ContextWithLogger added in v0.16.0

func ContextWithLogger(ctx context.Context, logger io.Writer) context.Context

func LoggerFromContext added in v0.16.0

func LoggerFromContext(ctx context.Context) io.Writer

func ValidateSnapshotId

func ValidateSnapshotId(id string) error

Types

type BackupProgressEntry

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

	// Error fields
	Error  any    `json:"error"`
	During string `json:"during"`
	Item   string `json:"item"`

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

	// Status fields
	PercentDone  float64  `json:"percent_done"`
	TotalFiles   int64    `json:"total_files"`
	FilesDone    int64    `json:"files_done"`
	TotalBytes   int64    `json:"total_bytes"`
	BytesDone    int64    `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
}

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 ErrorWithOutput added in v1.1.0

type ErrorWithOutput struct {
	Err    error
	Output string
}

func (*ErrorWithOutput) Error added in v1.1.0

func (e *ErrorWithOutput) Error() string

func (*ErrorWithOutput) Is added in v1.1.0

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

func (*ErrorWithOutput) Unwrap added in v1.1.0

func (e *ErrorWithOutput) 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 WithEnviron added in v0.11.0

func WithEnviron() GenericOption

func WithFlags

func WithFlags(flags ...string) GenericOption

func WithPrefixCommand added in v1.1.0

func WithPrefixCommand(args ...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   int64  `json:"uid"`
	Gid   int64  `json:"gid"`
	Size  int64  `json:"size"`
	Mode  int64  `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, uri string, opts ...GenericOption) *Repo

NewRepo instantiates a new repository.

func (*Repo) AddTags added in v1.0.0

func (r *Repo) AddTags(ctx context.Context, snapshotIDs []string, tags []string, opts ...GenericOption) error

AddTags adds tags to the specified snapshots.

func (*Repo) Backup

func (r *Repo) Backup(ctx context.Context, paths []string, progressCallback func(*BackupProgressEntry), opts ...GenericOption) (*BackupProgressEntry, error)

func (*Repo) Check added in v1.1.0

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

func (*Repo) Exists added in v1.1.0

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

Exists checks if the repository exists. Returns true if exists, false if it does not exist OR an access error occurred.

func (*Repo) Forget

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

func (*Repo) ForgetSnapshot added in v0.12.0

func (r *Repo) ForgetSnapshot(ctx context.Context, snapshotId string, opts ...GenericOption) error

func (*Repo) GenericCommand added in v1.0.0

func (r *Repo) GenericCommand(ctx context.Context, args []string, opts ...GenericOption) error

func (*Repo) Init

func (r *Repo) Init(ctx context.Context, opts ...GenericOption) 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    float64 `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"`
	SnapshotSummary SnapshotSummary `json:"summary"`
	// contains filtered or unexported fields
}

func (*Snapshot) UnixTimeMs

func (s *Snapshot) UnixTimeMs() int64

func (*Snapshot) Validate

func (s *Snapshot) Validate() error

type SnapshotSummary added in v1.4.0

type SnapshotSummary struct {
	BackupStart         string `json:"backup_start"`
	BackupEnd           string `json:"backup_end"`
	FilesNew            int64  `json:"files_new"`
	FilesChanged        int64  `json:"files_changed"`
	FilesUnmodified     int64  `json:"files_unmodified"`
	DirsNew             int64  `json:"dirs_new"`
	DirsChanged         int64  `json:"dirs_changed"`
	DirsUnmodified      int64  `json:"dirs_unmodified"`
	DataBlobs           int64  `json:"data_blobs"`
	TreeBlobs           int64  `json:"tree_blobs"`
	DataAdded           int64  `json:"data_added"`
	DataAddedPacked     int64  `json:"data_added_packed"`
	TotalFilesProcessed int64  `json:"total_files_processed"`
	TotalBytesProcessed int64  `json:"total_bytes_processed"`
	// contains filtered or unexported fields
}

func (*SnapshotSummary) DurationMs added in v1.4.0

func (s *SnapshotSummary) DurationMs() int64

Duration returns the duration of the snapshot in milliseconds.

Jump to

Keyboard shortcuts

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