backup

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package backup holds the OSS backup primitives around instance.Service: the local-directory blob store and the backup/restore job adapters (#66).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Svc *instance.Service
}

Handler runs "backup" jobs by delegating to instance.Service.Backup.

func (*Handler) Run

func (h *Handler) Run(ctx context.Context, job store.Job, jc *jobs.JobContext) error

Run unmarshals the job args into a BackupRequest and performs the backup, reporting progress through the job context.

type LocalDir

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

LocalDir is the OSS BlobStore: blobs are plain files under a root directory, written via temp-file + rename so a partial write is never visible as a complete blob.

A process crash mid-write can leave a .tmp-* file behind. Because the temp file lives inside the blob's key-prefix directory, a DeleteAll call on that prefix (e.g. to clean up a failed backup) reclaims it automatically.

func NewLocalDir

func NewLocalDir(root string) (*LocalDir, error)

NewLocalDir creates (if needed) and opens the root directory.

func (*LocalDir) DeleteAll

func (l *LocalDir) DeleteAll(_ context.Context, prefix string) error

func (*LocalDir) Get

func (l *LocalDir) Get(_ context.Context, key string) (io.ReadCloser, error)

func (*LocalDir) Put

type Reconciler

type Reconciler struct {
	Svc *instance.Service
}

Reconciler recovers "backup" jobs interrupted by a daemon restart: the backup row is failed (unless the work actually completed), partial blobs are deleted, and the instance is restarted.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, job store.Job, jc *jobs.JobContext) (store.JobState, string, bool, error)

Reconcile decodes the job args and drives the interrupted backup to a terminal state. Unparseable args are a permanent failure; an inconclusive host check (unreachable host) leaves the job reconciling for retry.

type RestoreHandler

type RestoreHandler struct {
	Svc *instance.Service
}

RestoreHandler runs "restore" jobs by delegating to instance.Service.Restore.

restore has no reconciler on purpose: an interrupted restore is resolved by boot recovery failing the job, and the operator re-running the restore — which is idempotent from the blob (it re-does teardown + import + verify).

func (*RestoreHandler) Run

func (h *RestoreHandler) Run(ctx context.Context, job store.Job, jc *jobs.JobContext) error

Run unmarshals the job args into a RestoreRequest and performs the restore, reporting progress through the job context.

Jump to

Keyboard shortcuts

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