Documentation
¶
Index ¶
- Constants
- Variables
- func FlowIDForSnapshotID(log *oplog.OpLog, snapshotID string) (int64, error)
- type BackupTask
- type BaseTask
- type CheckTask
- type CollectGarbageTask
- type GenericOneoffTask
- type HookVars
- func (v HookVars) EventName(cond v1.Hook_Condition) string
- func (v HookVars) FormatDuration(d time.Duration) string
- func (v HookVars) FormatSizeBytes(val any) string
- func (v HookVars) FormatTime(t time.Time) string
- func (v HookVars) IsError(cond v1.Hook_Condition) bool
- func (v HookVars) JsonMarshal(s any) string
- func (v HookVars) ShellEscape(s string) string
- func (v HookVars) Summary() (string, error)
- type OneoffTask
- type PruneTask
- type RetryBackoffPolicy
- type ScheduledTask
- type StatsTask
- type Task
- func NewCheckTask(repoID, planID string, force bool) Task
- func NewOneoffForgetSnapshotTask(repoID, planID string, flowID int64, at time.Time, snapshotID string) Task
- func NewOneoffForgetTask(repoID, planID string, flowID int64, at time.Time) Task
- func NewOneoffIndexSnapshotsTask(repoID string, at time.Time) Task
- func NewOneoffRestoreTask(repoID, planID string, flowID int64, at time.Time, ...) Task
- func NewOneoffRunCommandTask(repoID string, planID string, flowID int64, at time.Time, command string) Task
- func NewPruneTask(repoID, planID string, force bool) Task
- func NewStatsTask(repoID, planID string, force bool) Task
- type TaskCancelledError
- type TaskExecutor
- type TaskRetryError
- type TaskRunner
Constants ¶
View Source
const ( PlanForUnassociatedOperations = "_unassociated_" InstanceIDForUnassociatedOperations = "_unassociated_" PlanForSystemTasks = "_system_" // plan for system tasks e.g. garbage collection, prune, stats, etc. TaskPriorityStats = 0 TaskPriorityDefault = 1 << 1 // default priority TaskPriorityForget = 1 << 2 TaskPriorityIndexSnapshots = 1 << 3 TaskPriorityCheck = 1 << 4 // check should always run after prune. TaskPriorityPrune = 1 << 5 TaskPriorityInteractive = 1 << 6 // highest priority )
Variables ¶
View Source
var NeverScheduledTask = ScheduledTask{}
Functions ¶
Types ¶
type BackupTask ¶
type BackupTask struct {
BaseTask
// contains filtered or unexported fields
}
BackupTask is a scheduled backup operation.
func NewOneoffBackupTask ¶
func NewOneoffBackupTask(plan *v1.Plan, at time.Time) *BackupTask
func NewScheduledBackupTask ¶
func NewScheduledBackupTask(plan *v1.Plan) *BackupTask
func (*BackupTask) Next ¶
func (t *BackupTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*BackupTask) Run ¶
func (t *BackupTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type CheckTask ¶ added in v1.1.0
type CheckTask struct {
BaseTask
// contains filtered or unexported fields
}
func (*CheckTask) Next ¶ added in v1.1.0
func (t *CheckTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*CheckTask) Run ¶ added in v1.1.0
func (t *CheckTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type CollectGarbageTask ¶
type CollectGarbageTask struct {
BaseTask
// contains filtered or unexported fields
}
func NewCollectGarbageTask ¶
func NewCollectGarbageTask(logstore *logstore.LogStore) *CollectGarbageTask
func (*CollectGarbageTask) Next ¶
func (t *CollectGarbageTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*CollectGarbageTask) Run ¶
func (t *CollectGarbageTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type GenericOneoffTask ¶
type GenericOneoffTask struct {
OneoffTask
Do func(ctx context.Context, st ScheduledTask, runner TaskRunner) error
}
func (*GenericOneoffTask) Run ¶
func (g *GenericOneoffTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type HookVars ¶ added in v1.3.0
type HookVars struct {
Task string // the name of the task that triggered the hook.
Event v1.Hook_Condition // the event that triggered the hook.
Repo *v1.Repo // the v1.Repo that triggered the hook.
Plan *v1.Plan // the v1.Plan that triggered the hook.
SnapshotId string // the snapshot ID that triggered the hook.
SnapshotStats *restic.BackupProgressEntry // the summary of the backup operation.
CurTime time.Time // the current time as time.Time
Duration time.Duration // the duration of the operation that triggered the hook.
Error string // the error that caused the hook to run as a string.
}
HookVars is the set of variables that are available to a hook. Some of these are optional. NOTE: names of HookVars may change between versions of backrest. This is not a guaranteed stable API. when names change hooks will require updating.
func (HookVars) EventName ¶ added in v1.3.0
func (v HookVars) EventName(cond v1.Hook_Condition) string
func (HookVars) FormatDuration ¶ added in v1.3.0
func (HookVars) FormatSizeBytes ¶ added in v1.3.0
func (HookVars) JsonMarshal ¶ added in v1.3.0
func (HookVars) ShellEscape ¶ added in v1.3.0
type OneoffTask ¶
type OneoffTask struct {
BaseTask
RunAt time.Time
FlowID int64 // the ID of the flow this task is associated with.
DidSchedule bool
ProtoOp *v1.Operation // the prototype operation for this class of task.
}
func (*OneoffTask) Next ¶
func (o *OneoffTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
type PruneTask ¶
type PruneTask struct {
BaseTask
// contains filtered or unexported fields
}
func (*PruneTask) Next ¶
func (t *PruneTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*PruneTask) Run ¶
func (t *PruneTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type RetryBackoffPolicy ¶ added in v1.5.0
type ScheduledTask ¶
type ScheduledTask struct {
Task Task // the task to run
RunAt time.Time // the time at which the task should be run.
Op *v1.Operation // operation associated with this execution of the task.
}
ScheduledTask is a task that is scheduled to run at a specific time.
func (ScheduledTask) Eq ¶
func (s ScheduledTask) Eq(other ScheduledTask) bool
func (ScheduledTask) Less ¶
func (s ScheduledTask) Less(other ScheduledTask) bool
type StatsTask ¶
type StatsTask struct {
BaseTask
// contains filtered or unexported fields
}
func (*StatsTask) Next ¶
func (t *StatsTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*StatsTask) Run ¶
func (t *StatsTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type Task ¶
type Task interface {
Name() string // human readable name for this task.
Type() string // simple string 'type' for this task.
Next(now time.Time, runner TaskRunner) (ScheduledTask, error) // returns the next scheduled task.
Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error // run the task.
PlanID() string // the ID of the plan this task is associated with.
RepoID() string // the ID of the repo this task is associated with.
}
Task is a task that can be scheduled to run at a specific time.
func NewCheckTask ¶ added in v1.1.0
func NewOneoffForgetTask ¶
func NewOneoffRestoreTask ¶
func NewOneoffRunCommandTask ¶ added in v1.6.0
func NewPruneTask ¶
func NewStatsTask ¶
type TaskCancelledError ¶ added in v1.5.0
type TaskCancelledError struct {
}
TaskCancelledError is returned when a task is cancelled.
func (TaskCancelledError) Error ¶ added in v1.5.0
func (e TaskCancelledError) Error() string
func (TaskCancelledError) Is ¶ added in v1.5.0
func (e TaskCancelledError) Is(err error) bool
type TaskExecutor ¶ added in v1.3.0
type TaskExecutor interface {
RunTask(ctx context.Context, st ScheduledTask) error
}
type TaskRetryError ¶ added in v1.5.0
type TaskRetryError struct {
Err error
Backoff RetryBackoffPolicy
}
TaskRetryError is returned when a task should be retried after a specified backoff duration.
func (TaskRetryError) Error ¶ added in v1.5.0
func (e TaskRetryError) Error() string
func (TaskRetryError) Unwrap ¶ added in v1.5.0
func (e TaskRetryError) Unwrap() error
type TaskRunner ¶
type TaskRunner interface {
// CreateOperation creates the operation in storage and sets the operation ID in the task.
CreateOperation(*v1.Operation) error
// UpdateOperation updates the operation in storage. It must be called after CreateOperation.
UpdateOperation(*v1.Operation) error
// ExecuteHooks
ExecuteHooks(ctx context.Context, events []v1.Hook_Condition, vars HookVars) error
// OpLog returns the oplog for the operations.
OpLog() *oplog.OpLog
// GetRepo returns the repo with the given ID.
GetRepo(repoID string) (*v1.Repo, error)
// GetPlan returns the plan with the given ID.
GetPlan(planID string) (*v1.Plan, error)
// GetRepoOrchestrator returns the orchestrator for the repo with the given ID.
GetRepoOrchestrator(repoID string) (*repo.RepoOrchestrator, error)
// ScheduleTask schedules a task to run at a specific time.
ScheduleTask(task Task, priority int) error
// Config returns the current config.
Config() *v1.Config
// Logger returns the logger.
Logger(ctx context.Context) *zap.Logger
// LogrefWriter returns a writer that can be used to track streaming operation output.
LogrefWriter() (id string, w io.WriteCloser, err error)
}
TaskRunner is an interface for running tasks. It is used by tasks to create operations and write logs.
Click to show internal directories.
Click to hide internal directories.