Documentation ¶
Overview ¶
This package contains the code for the restic executable.
Index ¶
- Constants
- Variables
- func AddCleanupHandler(f func() error)
- func CleanupHandler(c <-chan os.Signal)
- func ClearLine() string
- func DeleteFiles(gopts GlobalOptions, repo restic.Repository, fileList restic.IDSet, ...)
- func DeleteFilesChecked(gopts GlobalOptions, repo restic.Repository, fileList restic.IDSet, ...) error
- func Exit(code int)
- func Exitf(exitcode int, format string, args ...interface{})
- func FilterLastSnapshots(list restic.Snapshots) restic.Snapshots
- func FindFilteredSnapshots(ctx context.Context, repo *repository.Repository, hosts []string, ...) <-chan *restic.Snapshot
- func OpenRepository(opts GlobalOptions) (*repository.Repository, error)
- func Print(args ...interface{})
- func PrintProgress(format string, args ...interface{})
- func PrintSnapshotGroupHeader(stdout io.Writer, groupKeyJSON string) error
- func PrintSnapshots(stdout io.Writer, list restic.Snapshots, reasons []restic.KeepReason, ...)
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func ReadPassword(opts GlobalOptions, prompt string) (string, error)
- func ReadPasswordTwice(gopts GlobalOptions, prompt1, prompt2 string) (string, error)
- func ReadRepo(opts GlobalOptions) (string, error)
- func RunBackup(opts BackupOptions, gopts GlobalOptions, term *termstatus.Terminal, ...) error
- func RunCache(opts CacheOptions, gopts GlobalOptions, args []string) error
- func RunCat(gopts GlobalOptions, args []string) error
- func RunCheck(opts CheckOptions, gopts GlobalOptions, args []string) error
- func RunCleanupHandlers()
- func RunCopy(opts CopyOptions, gopts GlobalOptions, args []string) error
- func RunDebug() error
- func RunDiff(opts DiffOptions, gopts GlobalOptions, args []string) error
- func RunDump(opts DumpOptions, gopts GlobalOptions, args []string) error
- func RunFind(opts FindOptions, gopts GlobalOptions, args []string) error
- func RunForget(opts ForgetOptions, gopts GlobalOptions, args []string) error
- func RunInit(opts InitOptions, gopts GlobalOptions, args []string) error
- func RunKey(gopts GlobalOptions, args []string) error
- func RunList(cmd *cobra.Command, opts GlobalOptions, args []string) error
- func RunMigrate(opts MigrateOptions, gopts GlobalOptions, args []string) error
- func RunMount(opts MountOptions, gopts GlobalOptions, args []string) error
- func RunOptions()
- func RunPrune(opts PruneOptions, gopts GlobalOptions) error
- func RunRecover(gopts GlobalOptions) error
- func RunRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error
- func RunSelfUpdate(opts SelfUpdateOptions, gopts GlobalOptions, args []string) error
- func RunSnapshots(opts SnapshotOptions, gopts GlobalOptions, args []string) error
- func RunStats(gopts GlobalOptions, args []string) error
- func RunUnlock(opts UnlockOptions, gopts GlobalOptions) error
- func RunVersion()
- func Verbosef(format string, args ...interface{})
- func Verboseff(format string, args ...interface{})
- func Warnf(format string, args ...interface{})
- type BackupOptions
- type CacheOptions
- type CheckOptions
- type Comparer
- type CopyOptions
- type DeviceMap
- type DiffOptions
- type DiffStat
- type DiffStats
- type DumpOptions
- type FindOptions
- type Finder
- type ForgetGroup
- type ForgetOptions
- type GlobalOptions
- type InitOptions
- type LsOptions
- type MigrateOptions
- type MountOptions
- type PruneOptions
- type RebuildIndexOptions
- type RejectByNameFunc
- type RejectFunc
- type RestoreOptions
- type SelfUpdateOptions
- type Snapshot
- type SnapshotGroup
- type SnapshotOptions
- type StatsOptions
- type TagOptions
- type UnlockOptions
Constants ¶
const TimeFormat = "2006-01-02 15:04:05"
TimeFormat is the format used for all timestamps printed by restic.
Variables ¶
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 ¶
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 ¶
Exitf uses Warnf to write the message and then terminates the process with the given exit code.
func FilterLastSnapshots ¶
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 ¶
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 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 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.
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 ¶
CacheOptions bundles all options for the snapshots command.
type CheckOptions ¶
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 ¶
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 ¶
NewDeviceMap creates a new device map from the list of source paths.
type DiffOptions ¶
type DiffOptions struct {
ShowMetadata bool
}
DiffOptions collects all options for the diff command.
type DiffStats ¶
type DiffStats struct { ChangedFiles int Added DiffStat Removed DiffStat BlobsBefore, BlobsAfter, BlobsCommon restic.BlobSet }
DiffStats collects the differences between two snapshots.
type DumpOptions ¶
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 ¶
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 ¶
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.
Source Files ¶
- cleanup.go
- delete.go
- doc.go
- exclude.go
- find.go
- format.go
- global.go
- global_release.go
- lock.go
- progress.go
- run_backup.go
- run_cache.go
- run_cat.go
- run_check.go
- run_copy.go
- run_diff.go
- run_dump.go
- run_find.go
- run_forget.go
- run_init.go
- run_key.go
- run_list.go
- run_ls.go
- run_migrate.go
- run_mount.go
- run_options.go
- run_prune.go
- run_rebuild_index.go
- run_recover.go
- run_restore.go
- run_self_update.go
- run_snapshots.go
- run_stats.go
- run_tag.go
- run_unlock.go
- run_version.go
- secondary_repo.go