entry

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: BSD-2-Clause Imports: 65 Imported by: 0

Documentation

Overview

This package contains the code for the restic executable.

Index

Constants

View Source
const TimeFormat = "2006-01-02 15:04:05"

TimeFormat is the format used for all timestamps printed by restic.

Variables

View Source
var ErrInvalidSourceData = errors.New("failed to read all source data during backup")

ErrInvalidSourceData is used to report an incomplete backup

Functions

func AddCleanupHandler

func AddCleanupHandler(f func() error)

AddCleanupHandler adds the function f to the list of cleanup handlers so that it is executed when all the cleanup handlers are run, e.g. when SIGINT is received.

func CleanupHandler

func CleanupHandler(c <-chan os.Signal)

CleanupHandler handles the SIGINT signals.

func ClearLine

func ClearLine() string

ClearLine creates a platform dependent string to clear the current line, so it can be overwritten. ANSI sequences are not supported on current windows cmd shell.

func DeleteFiles

func DeleteFiles(gopts GlobalOptions, repo restic.Repository, fileList restic.IDSet, fileType restic.FileType)

DeleteFiles deletes the given fileList of fileType in parallel it will print a warning if there is an error, but continue deleting the remaining files

func DeleteFilesChecked

func DeleteFilesChecked(gopts GlobalOptions, repo restic.Repository, fileList restic.IDSet, fileType restic.FileType) error

DeleteFilesChecked deletes the given fileList of fileType in parallel if an error occurs, it will cancel and return this error

func Exit

func Exit(code int)

Exit runs the cleanup handlers and then terminates the process with the given exit code.

func Exitf

func Exitf(exitcode int, format string, args ...interface{})

Exitf uses Warnf to write the message and then terminates the process with the given exit code.

func FilterLastSnapshots

func FilterLastSnapshots(list restic.Snapshots) restic.Snapshots

FilterLastSnapshots filters a list of snapshots to only return the last entry for each hostname and path. If the snapshot contains multiple paths, they will be joined and treated as one item.

func FindFilteredSnapshots

func FindFilteredSnapshots(ctx context.Context, repo *repository.Repository, hosts []string, tags []restic.TagList, paths []string, snapshotIDs []string) <-chan *restic.Snapshot

FindFilteredSnapshots yields Snapshots, either given explicitly by `snapshotIDs` or filtered from the list of all snapshots.

func OpenRepository

func OpenRepository(opts GlobalOptions) (*repository.Repository, error)

OpenRepository reads the password and opens the repository.

func Print

func Print(args ...interface{})

Print writes the message to the configured stdout stream.

func PrintProgress

func PrintProgress(format string, args ...interface{})

PrintProgress wraps fmt.Printf to handle the difference in writing progress information to terminals and non-terminal stdout

func PrintSnapshotGroupHeader

func PrintSnapshotGroupHeader(stdout io.Writer, groupKeyJSON string) error

PrintSnapshotGroupHeader prints which group of the group-by option the following snapshots belong to. Prints nothing, if we did not group at all.

func PrintSnapshots

func PrintSnapshots(stdout io.Writer, list restic.Snapshots, reasons []restic.KeepReason, compact bool)

PrintSnapshots prints a text table of the snapshots in list to stdout.

func Printf

func Printf(format string, args ...interface{})

Printf writes the message to the configured stdout stream.

func Println

func Println(args ...interface{})

Println writes the message to the configured stdout stream.

func ReadPassword

func ReadPassword(opts GlobalOptions, prompt string) (string, error)

ReadPassword reads the password from a password file, the environment variable RESTIC_PASSWORD or prompts the user.

func ReadPasswordTwice

func ReadPasswordTwice(gopts GlobalOptions, prompt1, prompt2 string) (string, error)

ReadPasswordTwice calls ReadPassword two times and returns an error when the passwords don't match.

func ReadRepo

func ReadRepo(opts GlobalOptions) (string, error)

func RunBackup

func RunBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Terminal, args []string) error

func RunCache

func RunCache(opts CacheOptions, gopts GlobalOptions, args []string) error

func RunCat

func RunCat(gopts GlobalOptions, args []string) error

func RunCheck

func RunCheck(opts CheckOptions, gopts GlobalOptions, args []string) error

func RunCleanupHandlers

func RunCleanupHandlers()

RunCleanupHandlers runs all registered cleanup handlers

func RunCopy

func RunCopy(opts CopyOptions, gopts GlobalOptions, args []string) error

func RunDebug

func RunDebug() error

runDebug is a noop without the debug tag.

func RunDiff

func RunDiff(opts DiffOptions, gopts GlobalOptions, args []string) error

func RunDump

func RunDump(opts DumpOptions, gopts GlobalOptions, args []string) error

func RunFind

func RunFind(opts FindOptions, gopts GlobalOptions, args []string) error

func RunForget

func RunForget(opts ForgetOptions, gopts GlobalOptions, args []string) error

func RunInit

func RunInit(opts InitOptions, gopts GlobalOptions, args []string) error

func RunKey

func RunKey(gopts GlobalOptions, args []string) error

func RunList

func RunList(cmd *cobra.Command, opts GlobalOptions, args []string) error

func RunMigrate

func RunMigrate(opts MigrateOptions, gopts GlobalOptions, args []string) error

func RunMount

func RunMount(opts MountOptions, gopts GlobalOptions, args []string) error

func RunOptions

func RunOptions()

func RunPrune

func RunPrune(opts PruneOptions, gopts GlobalOptions) error

func RunRecover

func RunRecover(gopts GlobalOptions) error

func RunRestore

func RunRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error

func RunSelfUpdate

func RunSelfUpdate(opts SelfUpdateOptions, gopts GlobalOptions, args []string) error

func RunSnapshots

func RunSnapshots(opts SnapshotOptions, gopts GlobalOptions, args []string) error

func RunStats

func RunStats(gopts GlobalOptions, args []string) error

func RunUnlock

func RunUnlock(opts UnlockOptions, gopts GlobalOptions) error

func RunVersion

func RunVersion()

func Verbosef

func Verbosef(format string, args ...interface{})

Verbosef calls Printf to write the message when the verbose flag is set.

func Verboseff

func Verboseff(format string, args ...interface{})

Verboseff calls Printf to write the message when the verbosity is >= 2

func Warnf

func Warnf(format string, args ...interface{})

Warnf writes the message to the configured stderr stream.

Types

type BackupOptions

type BackupOptions struct {
	Parent                  string
	Force                   bool
	Excludes                []string
	InsensitiveExcludes     []string
	ExcludeFiles            []string
	InsensitiveExcludeFiles []string
	ExcludeOtherFS          bool
	ExcludeIfPresent        []string
	ExcludeCaches           bool
	ExcludeLargerThan       string
	Stdin                   bool
	StdinFilename           string
	Tags                    restic.TagLists
	Host                    string
	FilesFrom               []string
	FilesFromVerbatim       []string
	FilesFromRaw            []string
	TimeStamp               string
	WithAtime               bool
	IgnoreInode             bool
	IgnoreCtime             bool
	UseFsSnapshot           bool
}

BackupOptions bundles all options for the backup command.

func (BackupOptions) Check

func (opts BackupOptions) Check(gopts GlobalOptions, args []string) error

Check returns an error when an invalid combination of options was set.

type CacheOptions

type CacheOptions struct {
	Cleanup bool
	MaxAge  uint
	NoSize  bool
}

CacheOptions bundles all options for the snapshots command.

type CheckOptions

type CheckOptions struct {
	ReadData       bool
	ReadDataSubset string
	CheckUnused    bool
	WithCache      bool
}

CheckOptions bundles all options for the 'check' command.

type Comparer

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

Comparer collects all things needed to compare two snapshots.

type CopyOptions

type CopyOptions struct {
	Hosts []string
	Tags  restic.TagLists
	Paths []string
	// contains filtered or unexported fields
}

CopyOptions bundles all options for the copy command.

type DeviceMap

type DeviceMap map[string]uint64

DeviceMap is used to track allowed source devices for backup. This is used to check for crossing mount points during backup (for --one-file-system). It maps the name of a source path to its device ID.

func NewDeviceMap

func NewDeviceMap(allowedSourcePaths []string) (DeviceMap, error)

NewDeviceMap creates a new device map from the list of source paths.

func (DeviceMap) IsAllowed

func (m DeviceMap) IsAllowed(item string, deviceID uint64) (bool, error)

IsAllowed returns true if the path is located on an allowed device.

type DiffOptions

type DiffOptions struct {
	ShowMetadata bool
}

DiffOptions collects all options for the diff command.

type DiffStat

type DiffStat struct {
	Files, Dirs, Others  int
	DataBlobs, TreeBlobs int
	Bytes                uint64
}

DiffStat collects stats for all types of items.

func (*DiffStat) Add

func (s *DiffStat) Add(node *restic.Node)

Add adds stats information for node to s.

type DiffStats

type DiffStats struct {
	ChangedFiles                         int
	Added                                DiffStat
	Removed                              DiffStat
	BlobsBefore, BlobsAfter, BlobsCommon restic.BlobSet
}

DiffStats collects the differences between two snapshots.

func NewDiffStats

func NewDiffStats() *DiffStats

NewDiffStats creates new stats for a diff run.

type DumpOptions

type DumpOptions struct {
	Hosts   []string
	Paths   []string
	Tags    restic.TagLists
	Archive string
}

DumpOptions collects all options for the dump command.

type FindOptions

type FindOptions struct {
	Oldest             string
	Newest             string
	Snapshots          []string
	BlobID, TreeID     bool
	PackID, ShowPackID bool
	CaseInsensitive    bool
	ListLong           bool
	Hosts              []string
	Paths              []string
	Tags               restic.TagLists
}

FindOptions bundles all options for the find command.

type Finder

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

Finder bundles information needed to find a file or directory.

type ForgetGroup

type ForgetGroup struct {
	Tags    []string            `json:"tags"`
	Host    string              `json:"host"`
	Paths   []string            `json:"paths"`
	Keep    []Snapshot          `json:"keep"`
	Remove  []Snapshot          `json:"remove"`
	Reasons []restic.KeepReason `json:"reasons"`
}

ForgetGroup helps to print what is forgotten in JSON.

type ForgetOptions

type ForgetOptions struct {
	Last     int
	Hourly   int
	Daily    int
	Weekly   int
	Monthly  int
	Yearly   int
	Within   restic.Duration
	KeepTags restic.TagLists

	Hosts   []string
	Tags    restic.TagLists
	Paths   []string
	Compact bool

	// Grouping
	GroupBy string
	DryRun  bool
	Prune   bool
}

ForgetOptions collects all options for the forget command.

type GlobalOptions

type GlobalOptions struct {
	Repo            string
	RepositoryFile  string
	PasswordFile    string
	PasswordCommand string
	KeyHint         string
	Quiet           bool
	Verbose         int
	NoLock          bool
	JSON            bool
	CacheDir        string
	NoCache         bool
	CACerts         []string
	TLSClientCert   string
	CleanupCache    bool

	LimitUploadKb   int
	LimitDownloadKb int

	Options []string
	// contains filtered or unexported fields
}

GlobalOptions hold all global options for restic.

type InitOptions

type InitOptions struct {
	CopyChunkerParameters bool
	// contains filtered or unexported fields
}

InitOptions bundles all options for the init command.

type LsOptions

type LsOptions struct {
	ListLong  bool
	Hosts     []string
	Tags      restic.TagLists
	Paths     []string
	Recursive bool
}

LsOptions collects all options for the ls command.

type MigrateOptions

type MigrateOptions struct {
	Force bool
}

MigrateOptions bundles all options for the 'check' command.

type MountOptions

type MountOptions struct {
	OwnerRoot            bool
	AllowOther           bool
	NoDefaultPermissions bool
	Hosts                []string
	Tags                 restic.TagLists
	Paths                []string
	SnapshotTemplate     string
}

MountOptions collects all options for the mount command.

type PruneOptions

type PruneOptions struct {
	DryRun bool

	MaxUnused string

	MaxRepackSize  string
	MaxRepackBytes uint64

	RepackCachableOnly bool
	// contains filtered or unexported fields
}

PruneOptions collects all options for the cleanup command.

type RebuildIndexOptions

type RebuildIndexOptions struct {
	ReadAllPacks bool
}

RebuildIndexOptions collects all options for the rebuild-index command.

type RejectByNameFunc

type RejectByNameFunc func(path string) bool

RejectByNameFunc is a function that takes a filename of a file that would be included in the backup. The function returns true if it should be excluded (rejected) from the backup.

type RejectFunc

type RejectFunc func(path string, fi os.FileInfo) bool

RejectFunc is a function that takes a filename and os.FileInfo of a file that would be included in the backup. The function returns true if it should be excluded (rejected) from the backup.

type RestoreOptions

type RestoreOptions struct {
	Exclude            []string
	InsensitiveExclude []string
	Include            []string
	InsensitiveInclude []string
	Target             string
	Hosts              []string
	Paths              []string
	Tags               restic.TagLists
	Verify             bool
}

RestoreOptions collects all options for the restore command.

type SelfUpdateOptions

type SelfUpdateOptions struct {
	Output string
}

SelfUpdateOptions collects all options for the update-restic command.

type Snapshot

type Snapshot struct {
	*restic.Snapshot

	ID      *restic.ID `json:"id"`
	ShortID string     `json:"short_id"`
}

Snapshot helps to print Snaphots as JSON with their ID included.

type SnapshotGroup

type SnapshotGroup struct {
	GroupKey  restic.SnapshotGroupKey `json:"group_key"`
	Snapshots []Snapshot              `json:"snapshots"`
}

SnapshotGroup helps to print SnaphotGroups as JSON with their GroupReasons included.

type SnapshotOptions

type SnapshotOptions struct {
	Hosts   []string
	Tags    restic.TagLists
	Paths   []string
	Compact bool
	Last    bool
	GroupBy string
}

SnapshotOptions bundles all options for the snapshots command.

type StatsOptions

type StatsOptions struct {

	// filter snapshots by, if given by user
	Hosts []string
	Tags  restic.TagLists
	Paths []string
	// contains filtered or unexported fields
}

StatsOptions collects all options for the stats command.

type TagOptions

type TagOptions struct {
	Hosts      []string
	Paths      []string
	Tags       restic.TagLists
	SetTags    restic.TagLists
	AddTags    restic.TagLists
	RemoveTags restic.TagLists
}

TagOptions bundles all options for the 'tag' command.

type UnlockOptions

type UnlockOptions struct {
	RemoveAll bool
}

UnlockOptions collects all options for the unlock command.

Jump to

Keyboard shortcuts

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