Documentation
¶
Index ¶
- func FindOrInstall() (string, error)
- func GetPresetExcludes(name string) []string
- func GetPresetPreHook(name string) string
- func MergeExcludes(presets []string, custom []string) []string
- type BackupOptions
- type BackupSummary
- type FileEntry
- type Lock
- type ProgressEntry
- type RepoStats
- type Runner
- func (r *Runner) Backup(ctx context.Context, opts BackupOptions, onProgress func(ProgressEntry)) (*BackupSummary, error)
- func (r *Runner) Check(ctx context.Context) error
- func (r *Runner) Dump(ctx context.Context, snapshotID string, filePath string) ([]byte, error)
- func (r *Runner) Forget(ctx context.Context, keepLast, keepDaily, keepWeekly, keepMonthly int) error
- func (r *Runner) ForgetSnapshot(ctx context.Context, snapshotID string) error
- func (r *Runner) Init(ctx context.Context) error
- func (r *Runner) IsInitialized(ctx context.Context) bool
- func (r *Runner) LsFiles(ctx context.Context, snapshotID string, maxFiles int) ([]FileEntry, error)
- func (r *Runner) Prune(ctx context.Context) error
- func (r *Runner) Restore(ctx context.Context, snapshotID string, target string, includes []string, ...) error
- func (r *Runner) Snapshots(ctx context.Context) ([]Snapshot, error)
- func (r *Runner) Stats(ctx context.Context) (*RepoStats, error)
- func (r *Runner) UnlockIfStale(ctx context.Context, maxAge time.Duration) error
- func (r *Runner) Version(ctx context.Context) string
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindOrInstall ¶
FindOrInstall locates restic in PATH, or downloads it.
func GetPresetExcludes ¶
GetPresetExcludes returns the exclude patterns for a named preset.
func GetPresetPreHook ¶
GetPresetPreHook returns the embedded pre-backup hook script for a preset, if any.
func MergeExcludes ¶
MergeExcludes combines preset excludes with custom exclude patterns.
Types ¶
type BackupOptions ¶
type BackupOptions struct {
Paths []string
Excludes []string
Tags []string
BandwidthLimitKiB int
OnStarted func(pid int) // called after restic process starts, with its PID
}
BackupOptions configures a backup run.
type BackupSummary ¶
type BackupSummary struct {
MessageType string `json:"message_type"`
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 int64 `json:"data_added"`
TotalFilesProcessed int `json:"total_files_processed"`
TotalBytesProcessed int64 `json:"total_bytes_processed"`
TotalDuration float64 `json:"total_duration"`
SnapshotID string `json:"snapshot_id"`
}
BackupSummary is the final "summary" message from restic backup --json.
type FileEntry ¶ added in v0.2.7
type FileEntry struct {
Path string `json:"path"`
Size int64 `json:"size"`
ModifiedAt string `json:"modified_at"`
}
FileEntry represents a file in a snapshot listing.
type Lock ¶
type Lock struct {
Time time.Time `json:"time"`
Exclusive bool `json:"exclusive"`
Hostname string `json:"hostname"`
Username string `json:"username"`
PID int `json:"pid"`
UID int `json:"uid"`
GID int `json:"gid"`
}
Lock represents a restic lock entry.
type ProgressEntry ¶
type ProgressEntry struct {
MessageType string `json:"message_type"`
SecondsElapsed float64 `json:"seconds_elapsed,omitempty"`
PercentDone float64 `json:"percent_done,omitempty"`
TotalFiles int `json:"total_files,omitempty"`
FilesDone int `json:"files_done,omitempty"`
TotalBytes int64 `json:"total_bytes,omitempty"`
BytesDone int64 `json:"bytes_done,omitempty"`
CurrentFiles []string `json:"current_files,omitempty"`
}
ProgressEntry is emitted by restic --json during backup.
type RepoStats ¶
type RepoStats struct {
TotalSize int64 `json:"total_size"`
TotalFileCount int `json:"total_file_count"`
}
RepoStats from restic stats.
type Runner ¶
Runner wraps the restic CLI.
func NewRunner ¶
func NewRunner(binary string, repoURI string, password string, storageEnv map[string]string) *Runner
NewRunner creates a runner with the given environment.
func (*Runner) Backup ¶
func (r *Runner) Backup(ctx context.Context, opts BackupOptions, onProgress func(ProgressEntry)) (*BackupSummary, error)
Backup runs a backup and streams progress.
func (*Runner) Forget ¶
func (r *Runner) Forget(ctx context.Context, keepLast, keepDaily, keepWeekly, keepMonthly int) error
Forget removes old snapshots per retention policy.
func (*Runner) ForgetSnapshot ¶ added in v0.7.0
ForgetSnapshot removes a specific snapshot by ID without pruning.
func (*Runner) IsInitialized ¶
IsInitialized checks if the repo is initialized by running snapshots.
func (*Runner) LsFiles ¶ added in v0.2.7
LsFiles lists files in a snapshot, limited to maxFiles entries.
func (*Runner) Restore ¶
func (r *Runner) Restore(ctx context.Context, snapshotID string, target string, includes []string, excludes []string) error
Restore restores a snapshot to a target directory.
func (*Runner) UnlockIfStale ¶
UnlockIfStale removes locks older than maxAge.