resticProxy

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: GPL-3.0 Imports: 77 Imported by: 0

Documentation

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("at least one source file could not be read")
View Source
var ErrNegativePolicyCount = errors.New("negative values not allowed, use 'unlimited' instead")

Functions

func AutoCheck

func AutoCheck()

func AutoRebuildIndex

func AutoRebuildIndex()

func BackupLock

func BackupLock(repo int, path string) bool

BackupLock 备份任务锁

func BackupUnLock

func BackupUnLock(repo int, path string)

func CheckRepoStatus

func CheckRepoStatus(repoid int) *restic.Config

CheckRepoStatus 检测仓库状态

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

func FilterLastestSnapshots(list restic.Snapshots, limit int) restic.Snapshots

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 GetAllLock() []model.LockInfo

func GetAllRepoStats

func GetAllRepoStats()

GetAllRepoStats 获取所有仓库状态

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 RunBackup

func RunBackup(opts BackupOptions, repoid int, taskinfo task.TaskInfo) error

func RunCheck

func RunCheck(opts CheckOptions, repoid int) (int, 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 RunForget

func RunForget(opts ForgetOptions, repoid int, snapshotids []string) (int, error)

func RunForgetSync

func RunForgetSync(opts ForgetOptions, repoid int, snapshotids []string) error

func RunInit

func RunInit(ctx context.Context, gopts GlobalOptions) (version uint, error error)

func RunLoadIndex

func RunLoadIndex(repoid int) error

func RunMigrate added in v1.2.0

func RunMigrate(opts MigrateOptions, repoid int, action string) (int, error)

func RunPrune

func RunPrune(opts PruneOptions, repoid int) (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)

func UnlockRepoById added in v1.2.0

func UnlockRepoById(repoid int, removeAll bool) (uint, 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)

func (*BackupOptions) Empty added in v1.2.0

func (opts *BackupOptions) Empty() bool

type CheckOptions

type CheckOptions struct {
	ReadData       bool   //read all data blobs
	ReadDataSubset string //read a `subset` of data packs, specified as 'n/t' for specific subset or either 'x%' or 'x.y%' for random subset
	CheckUnused    bool   //find unused blobs
	WithCache      bool   //use the cache
	NoLock         bool
}

type CleanCtx

type CleanCtx struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewCleanCtx

func NewCleanCtx() *CleanCtx

func (*CleanCtx) AddCleanCtx

func (c *CleanCtx) AddCleanCtx(f func())

func (*CleanCtx) Cleanup

func (c *CleanCtx) Cleanup()

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 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 HostParm

type HostParm struct {
	Name  string   `json:"name"`
	Paths []string `json:"paths"`
}

type LsRes

type LsRes struct {
	Snapshot lsSnapshot    `json:"snapshot"`
	Nodes    []interface{} `json:"nodes"`
}

func RunFind

func RunFind(targetP string, repoid int, snapshotid string) (*LsRes, error)

func RunLs

func RunLs(targetP string, repoid int, snapshotid string) (*LsRes, error)

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

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 Repository

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

func GetRepository

func GetRepository(repoid int) (*Repository, error)

GetRepository 获取仓库操作对象

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 SnapshotParm struct {
	Parms []HostParm `json:"parms"`
	Tags  []string   `json:"tags"`
}

func GetParms

func GetParms(repoid int, hosts []string) (*SnapshotParm, error)

type SnapshotRes

type SnapshotRes struct {
	*restic.Snapshot

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

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 (t *TaskProgress) CompleteItem(messageType string, item string, s archiver.ItemStats, d time.Duration)

func (*TaskProgress) E

func (t *TaskProgress) E(msg string, args ...interface{})

func (*TaskProgress) Error

func (t *TaskProgress) Error(item string, err error) error

func (*TaskProgress) Finish

func (t *TaskProgress) Finish(snapshotID restic.ID, start time.Time, summary *backup.Summary, dryRun bool)

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) Update

func (t *TaskProgress) Update(total, processed backup.Counter, errors uint, currentFiles map[string]struct{}, start time.Time, secs uint64)

func (*TaskProgress) UpdateTaskInfo

func (t *TaskProgress) UpdateTaskInfo(task wsTaskInfo.WsTaskInfo)

func (*TaskProgress) V

func (t *TaskProgress) V(msg string, args ...interface{})

Jump to

Keyboard shortcuts

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