Documentation ¶
Index ¶
- Constants
- Variables
- func AutoCheck()
- func AutoRebuildIndex()
- func BackupLock(repo int, path string) bool
- func BackupUnLock(repo int, path string)
- func CheckRepoStatus(repoid int) *restic.Config
- func DeleteFiles(spr *wsTaskInfo.Sprintf, ctx context.Context, repo restic.Repository, ...)
- func DeleteFilesChecked(spr *wsTaskInfo.Sprintf, ctx context.Context, repo restic.Repository, ...) error
- func FilterLastestSnapshots(list restic.Snapshots, limit int) restic.Snapshots
- func FindFilteredSnapshots(ctx context.Context, be restic.Lister, loader restic.LoaderUnpacked, ...) <-chan *restic.Snapshot
- func GetAllLock() []model.LockInfo
- func GetAllRepoStats()
- func GetAllRepoWithStatus(repotype int, name string) ([]repoModel.Repository, error)
- func InitRepository()
- func NewRestorePrinter(t wsTaskInfo.WsTaskInfo) *restorePrinter
- func OpenRepository(ctx context.Context, opts GlobalOptions) (*repository.Repository, error)
- func PrintSnapshots(spr *wsTaskInfo.Sprintf, list restic.Snapshots, reasons []restic.KeepReason, ...)
- func ReadRepo(opts GlobalOptions) (string, error)
- func RunBackup(opts BackupOptions, repoid int, taskinfo task.TaskInfo) error
- func RunCheck(opts CheckOptions, repoid int) (int, error)
- func RunCheckSync(ctx context.Context, opts CheckOptions, gopts GlobalOptions, ...) error
- func RunForget(opts ForgetOptions, repoid int, snapshotids []string) (int, error)
- func RunForgetSync(opts ForgetOptions, repoid int, snapshotids []string) error
- func RunInit(ctx context.Context, gopts GlobalOptions) (version uint, error error)
- func RunLoadIndex(repoid int) error
- func RunMigrate(opts MigrateOptions, repoid int, action string) (int, error)
- func RunPrune(opts PruneOptions, repoid int) (int, error)
- func RunRebuildIndex(opts RebuildIndexOptions, repoid int) (int, error)
- func RunRestore(opts RestoreOptions, repoid int, snapshotid string) error
- func RunSnapshots(opts SnapshotOptions, repoid int, snapshotids []string) ([]interface{}, error)
- func UnlockRepoById(repoid int, removeAll bool) (uint, error)
- type BackupOptions
- type CheckOptions
- type CleanCtx
- type DeviceMap
- type ForgetOptions
- type ForgetPolicyCount
- type GlobalOptions
- type HostParm
- type LsRes
- type MigrateOptions
- type PruneOptions
- type RebuildIndexOptions
- type RejectByNameFunc
- type RejectFunc
- type Repository
- type RepositoryHandler
- type RestoreOptions
- type SnapshotOptions
- type SnapshotParm
- type SnapshotRes
- type StatsContainer
- type StatsOptions
- type TaskProgress
- func (t *TaskProgress) CompleteItem(messageType string, item string, s archiver.ItemStats, d time.Duration)
- func (t *TaskProgress) E(msg string, args ...interface{})
- func (t *TaskProgress) Error(item string, err error) error
- func (t *TaskProgress) Finish(snapshotID restic.ID, start time.Time, summary *backup.Summary, dryRun bool)
- func (t *TaskProgress) P(msg string, args ...interface{})
- func (t *TaskProgress) ReportTotal(start time.Time, s archiver.ScanStats)
- func (t *TaskProgress) Reset()
- func (t *TaskProgress) ScannerError(item string, err error) error
- func (t *TaskProgress) SetWeight(weightCount, weightSize float64)
- func (t *TaskProgress) Update(total, processed backup.Counter, errors uint, currentFiles map[string]struct{}, ...)
- func (t *TaskProgress) UpdateTaskInfo(task wsTaskInfo.WsTaskInfo)
- func (t *TaskProgress) V(msg string, args ...interface{})
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("at least one source file could not be read")
var ErrNegativePolicyCount = errors.New("negative values not allowed, use 'unlimited' instead")
Functions ¶
func AutoRebuildIndex ¶
func AutoRebuildIndex()
func BackupUnLock ¶
func DeleteFiles ¶
func DeleteFiles(spr *wsTaskInfo.Sprintf, ctx context.Context, 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(spr *wsTaskInfo.Sprintf, ctx context.Context, 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 FilterLastestSnapshots ¶
FilterLastestSnapshots filters a list of snapshots to only return the limit last entries 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, be restic.Lister, loader restic.LoaderUnpacked, f *restic.SnapshotFilter, snapshotIDs []string) <-chan *restic.Snapshot
FindFilteredSnapshots yields Snapshots, either given explicitly by `snapshotIDs` or filtered from the list of all snapshots.
func GetAllLock ¶
func GetAllRepoWithStatus ¶
func GetAllRepoWithStatus(repotype int, name string) ([]repoModel.Repository, error)
GetAllRepoWithStatus 获取仓库列表并带状态信息
func InitRepository ¶
func InitRepository()
func NewRestorePrinter ¶ added in v1.2.0
func NewRestorePrinter(t wsTaskInfo.WsTaskInfo) *restorePrinter
func OpenRepository ¶
func OpenRepository(ctx context.Context, opts GlobalOptions) (*repository.Repository, error)
OpenRepository reads the password and opens the repository.
func PrintSnapshots ¶
func PrintSnapshots(spr *wsTaskInfo.Sprintf, list restic.Snapshots, reasons []restic.KeepReason, compact bool)
PrintSnapshots prints a text table of the snapshots in list to stdout.
func ReadRepo ¶
func ReadRepo(opts GlobalOptions) (string, error)
func RunCheckSync ¶ added in v1.2.1
func RunCheckSync(ctx context.Context, opts CheckOptions, gopts GlobalOptions, repo *repository.Repository, spr *wsTaskInfo.Sprintf) error
func RunForgetSync ¶
func RunForgetSync(opts ForgetOptions, repoid int, snapshotids []string) error
func RunLoadIndex ¶
func RunMigrate ¶ added in v1.2.0
func RunMigrate(opts MigrateOptions, repoid int, action string) (int, error)
func RunRebuildIndex ¶
func RunRebuildIndex(opts RebuildIndexOptions, repoid int) (int, error)
func RunRestore ¶
func RunRestore(opts RestoreOptions, repoid int, snapshotid string) error
func RunSnapshots ¶
func RunSnapshots(opts SnapshotOptions, repoid int, snapshotids []string) ([]interface{}, error)
Types ¶
type BackupOptions ¶
type BackupOptions struct { Parent string GroupBy restic.SnapshotGroupByOptions Force bool ExcludeOtherFS bool ExcludeIfPresent []string ExcludeCaches bool ExcludeLargerThan string Tags restic.TagLists Host string TimeStamp string // `time` of the backup (ex. '2012-11-01 22:08:41') (default: now) WithAtime bool IgnoreInode bool IgnoreCtime bool UseFsSnapshot bool DryRun bool ReadConcurrency uint //读取并发数量,默认2 // contains filtered or unexported fields }
BackupOptions bundles all options for the backup command.
func (BackupOptions) CollectPatterns ¶ added in v1.2.0
func (opts BackupOptions) CollectPatterns() ([]RejectByNameFunc, error)
type CheckOptions ¶
type CleanCtx ¶
func NewCleanCtx ¶
func NewCleanCtx() *CleanCtx
func (*CleanCtx) AddCleanCtx ¶
func (c *CleanCtx) AddCleanCtx(f func())
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 ForgetOptions ¶
type ForgetOptions struct { Last ForgetPolicyCount Hourly ForgetPolicyCount Daily ForgetPolicyCount Weekly ForgetPolicyCount Monthly ForgetPolicyCount Yearly ForgetPolicyCount Within restic.Duration WithinHourly restic.Duration WithinDaily restic.Duration WithinWeekly restic.Duration WithinMonthly restic.Duration WithinYearly restic.Duration KeepTags restic.TagLists restic.SnapshotFilter Compact bool //use compact output format // Grouping GroupBy restic.SnapshotGroupByOptions DryRun bool Prune bool // automatically run the 'prune' command if snapshots have been removed }
ForgetOptions collects all options for the forget command.
type ForgetPolicyCount ¶ added in v1.2.0
type ForgetPolicyCount int
func (*ForgetPolicyCount) Set ¶ added in v1.2.0
func (c *ForgetPolicyCount) Set(s string) error
func (*ForgetPolicyCount) String ¶ added in v1.2.0
func (c *ForgetPolicyCount) String() string
func (*ForgetPolicyCount) Type ¶ added in v1.2.0
func (c *ForgetPolicyCount) Type() string
type GlobalOptions ¶
type GlobalOptions struct { Repo string KeyHint string Quiet bool Verbose int NoLock bool RetryLock time.Duration JSON bool CacheDir string NoCache bool CleanupCache bool Compression repository.CompressionMode PackSize uint NoExtraVerify bool backend.TransportOptions limiter.Limits // AWS_ACCESS_KEY_ID KeyId string // AWS_SECRET_ACCESS_KEY Secret string // AWS_DEFAULT_REGION Region string // GOOGLE_PROJECT_ID ProjectID string // AZURE_ACCOUNT_NAME AccountName string // AZURE_ACCOUNT_KEY,B2_ACCOUNT_KEY AccountKey string // B2_ACCOUNT_ID AccountID string Options []string RepositoryVersion string // contains filtered or unexported fields }
GlobalOptions hold all global options for restic.
func GetGlobalOptions ¶
func GetGlobalOptions(rep repoModel.Repository) (GlobalOptions, context.CancelFunc)
GetGlobalOptions 获取仓库配置
type LsRes ¶
type LsRes struct { Snapshot lsSnapshot `json:"snapshot"` Nodes []interface{} `json:"nodes"` }
type MigrateOptions ¶ added in v1.2.0
type MigrateOptions struct {
Force bool
}
MigrateOptions bundles all options for the 'check' command.
type PruneOptions ¶
type PruneOptions struct { DryRun bool UnsafeNoSpaceRecovery string MaxUnused string MaxRepackSize string MaxRepackBytes uint64 RepackCachableOnly bool RepackSmall bool RepackUncompressed bool // contains filtered or unexported fields }
PruneOptions collects all options for the cleanup command.
type RebuildIndexOptions ¶
type RebuildIndexOptions struct {
ReadAllPacks bool //read all pack files to generate new index from scratch
}
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 Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
type RepositoryHandler ¶
type RepositoryHandler struct {
// contains filtered or unexported fields
}
var Myrepositorys RepositoryHandler
func (*RepositoryHandler) Get ¶
func (rh *RepositoryHandler) Get(key int) Repository
func (*RepositoryHandler) Remove ¶
func (rh *RepositoryHandler) Remove(key int)
func (*RepositoryHandler) Set ¶
func (rh *RepositoryHandler) Set(key int, rep Repository)
type RestoreOptions ¶
type RestoreOptions struct { Exclude []string //exclude a `pattern` (can be specified multiple times) InsensitiveExclude []string //same as `--exclude` but ignores the casing of filenames Include []string //include a `pattern`, exclude everything else (can be specified multiple times) InsensitiveInclude []string //same as `--include` but ignores the casing of filenames Target string //directory to extract data to restic.SnapshotFilter Sparse bool //restore files as sparse Verify bool //verify restored files content }
RestoreOptions collects all options for the restore command.
type SnapshotOptions ¶
type SnapshotOptions struct { restic.SnapshotFilter Compact bool Last bool // This option should be removed in favour of Latest. Latest int GroupBy restic.SnapshotGroupByOptions }
type SnapshotParm ¶
type SnapshotRes ¶
type StatsContainer ¶
type StatsContainer struct { TotalSize uint64 `json:"total_size"` TotalUncompressedSize uint64 `json:"total_uncompressed_size,omitempty"` TotalCompressedBlobsSize uint64 `json:"-"` TotalCompressedBlobsUncompressedSize uint64 `json:"-"` CompressionRatio float64 `json:"compression_ratio,omitempty"` CompressionProgress float64 `json:"compression_progress,omitempty"` CompressionSpaceSaving float64 `json:"compression_space_saving,omitempty"` TotalFileCount uint64 `json:"total_file_count,omitempty"` TotalBlobCount uint64 `json:"total_blob_count,omitempty"` // holds count of all considered snapshots SnapshotsCount int `json:"snapshots_count"` // contains filtered or unexported fields }
statsContainer holds information during a walk of a repository to collect information about it, as well as state needed for a successful and efficient walk.
type StatsOptions ¶
type StatsOptions struct { restic.SnapshotFilter // contains filtered or unexported fields }
type TaskProgress ¶
type TaskProgress struct { *ui.StdioWrapper // contains filtered or unexported fields }
func NewTaskProgress ¶
func NewTaskProgress(task wsTaskInfo.WsTaskInfo, minUpdatePause time.Duration) *TaskProgress
func (*TaskProgress) CompleteItem ¶
func (*TaskProgress) E ¶
func (t *TaskProgress) E(msg string, args ...interface{})
func (*TaskProgress) P ¶
func (t *TaskProgress) P(msg string, args ...interface{})
func (*TaskProgress) ReportTotal ¶
func (t *TaskProgress) ReportTotal(start time.Time, s archiver.ScanStats)
func (*TaskProgress) Reset ¶
func (t *TaskProgress) Reset()
func (*TaskProgress) ScannerError ¶
func (t *TaskProgress) ScannerError(item string, err error) error
func (*TaskProgress) SetWeight ¶ added in v1.1.1
func (t *TaskProgress) SetWeight(weightCount, weightSize float64)
func (*TaskProgress) UpdateTaskInfo ¶
func (t *TaskProgress) UpdateTaskInfo(task wsTaskInfo.WsTaskInfo)
func (*TaskProgress) V ¶
func (t *TaskProgress) V(msg string, args ...interface{})
Source Files ¶
- backup_lock.go
- backup_printer.go
- clean_context.go
- delete.go
- exclude.go
- find.go
- global.go
- lock.go
- log_progress.go
- restic_backup.go
- restic_check.go
- restic_find.go
- restic_forget.go
- restic_init.go
- restic_load_index.go
- restic_ls.go
- restic_migrate.go
- restic_prune.go
- restic_rebuild_index.go
- restic_restore.go
- restic_snapshots.go
- restic_stats.go
- restore_printer.go