backup

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: GPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrComponentNotFound = errors.New("the backup has no such component with a snapshot")
View Source
var ErrPathNotFound = errors.New("the backup does not contain that path")
View Source
var ErrRepositoryBusy = errors.New("the backup repository is in use by another operation; try again once it finishes")
View Source
var ErrRunNotFound = errors.New("backup run not found")

Functions

func BuildComponents

func BuildComponents(project *composeProject, stackPath, backupLocation string) ([]Component, []SkippedMount, error)

func RunStartupHygiene

func RunStartupHygiene(lc fx.Lifecycle, service *Service)

Types

type Component

type Component struct {
	ID              string            `json:"id"`
	Kind            ComponentKind     `json:"kind"`
	VolumeName      string            `json:"volume_name,omitempty"`
	VolumeDef       *VolumeDefinition `json:"volume_def,omitempty"`
	SourcePath      string            `json:"source_path,omitempty"`
	Service         string            `json:"service,omitempty"`
	Target          string            `json:"target,omitempty"`
	ContainerNumber string            `json:"container_number,omitempty"`
	IsFile          bool              `json:"is_file,omitempty"`
	Excludes        []string          `json:"excludes,omitempty"`
	SnapshotID      string            `json:"snapshot_id,omitempty"`
	FilesNew        uint64            `json:"files_new"`
	FilesChanged    uint64            `json:"files_changed"`
	FilesUnmodified uint64            `json:"files_unmodified"`
	BytesAdded      uint64            `json:"bytes_added"`
	BytesProcessed  uint64            `json:"bytes_processed"`
	DurationSecs    float64           `json:"duration_secs"`
	Error           string            `json:"error,omitempty"`
}

type ComponentKind

type ComponentKind string
const (
	KindStackDirectory  ComponentKind = "stack-directory"
	KindVolume          ComponentKind = "volume"
	KindBindMount       ComponentKind = "bind-mount"
	KindAnonymousVolume ComponentKind = "anonymous-volume"
)

type CreateOptions

type CreateOptions struct {
	StopMode string
	Label    string
	Password string
}

type DeleteBackupRequest

type DeleteBackupRequest struct {
	BackupPassword string `json:"backup_password"`
}

type FileEntry

type FileEntry struct {
	Name  string    `json:"name"`
	Type  string    `json:"type"`
	Size  uint64    `json:"size"`
	MTime time.Time `json:"mtime"`
}

type FileListing

type FileListing struct {
	Path    string      `json:"path"`
	Entries []FileEntry `json:"entries"`
}

type Handler

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

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) DeleteStackBackup

func (h *Handler) DeleteStackBackup(c echo.Context) error

func (*Handler) DownloadBackupFiles

func (h *Handler) DownloadBackupFiles(c echo.Context) error

func (*Handler) GetBackupsOverview

func (h *Handler) GetBackupsOverview(c echo.Context) error

func (*Handler) GetStackBackup

func (h *Handler) GetStackBackup(c echo.Context) error

func (*Handler) ListBackupFiles

func (h *Handler) ListBackupFiles(c echo.Context) error

func (*Handler) ListStackBackups

func (h *Handler) ListStackBackups(c echo.Context) error

type ListBackupsResponse

type ListBackupsResponse struct {
	Configured bool         `json:"configured"`
	Total      int          `json:"total"`
	Runs       []RunSummary `json:"runs"`
}

type Overview

type Overview struct {
	Configured bool                 `json:"configured"`
	Stacks     []StackBackupSummary `json:"stacks"`
}

type ProgressWriter

type ProgressWriter interface {
	WriteStdout(message string)
	WriteStderr(message string)
	WriteProgress(message string)
}

type RestoreOptions

type RestoreOptions struct {
	BackupID       string
	ComponentIDs   []string
	StopMode       string
	KeepExtraFiles bool
	Sparse         bool
	Password       string
}

type Run

type Run struct {
	ID            string         `json:"id"`
	StackName     string         `json:"stack_name"`
	StartedAt     time.Time      `json:"started_at"`
	FinishedAt    *time.Time     `json:"finished_at,omitempty"`
	Status        RunStatus      `json:"status"`
	Label         string         `json:"label,omitempty"`
	StopMode      string         `json:"stop_mode,omitempty"`
	ResticVersion string         `json:"restic_version,omitempty"`
	Verified      *bool          `json:"verified,omitempty"`
	VerifyError   string         `json:"verify_error,omitempty"`
	RepoSizeBytes uint64         `json:"repo_size_bytes,omitempty"`
	Components    []Component    `json:"components"`
	Skipped       []SkippedMount `json:"skipped,omitempty"`
	Error         string         `json:"error,omitempty"`
}

type RunPersistence

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

func NewRunPersistence

func NewRunPersistence(persistenceDir string, logger *logging.Logger) (*RunPersistence, error)

func (*RunPersistence) DeleteRun

func (p *RunPersistence) DeleteRun(stackName, runID string) error

func (*RunPersistence) HasRecordedSnapshots

func (p *RunPersistence) HasRecordedSnapshots(stackName string) (bool, error)

func (*RunPersistence) ListStacksWithRuns

func (p *RunPersistence) ListStacksWithRuns() ([]string, error)

func (*RunPersistence) LoadRun

func (p *RunPersistence) LoadRun(stackName, runID string) (*Run, error)

func (*RunPersistence) LoadStackRuns

func (p *RunPersistence) LoadStackRuns(stackName string) ([]*Run, error)

func (*RunPersistence) PersistRun

func (p *RunPersistence) PersistRun(run *Run) error

func (*RunPersistence) RunSummaries

func (p *RunPersistence) RunSummaries(stackName string) ([]RunSummary, error)

type RunStatus

type RunStatus string
const (
	StatusRunning     RunStatus = "running"
	StatusCompleted   RunStatus = "completed"
	StatusFailed      RunStatus = "failed"
	StatusInterrupted RunStatus = "interrupted"
)

type RunSummary

type RunSummary struct {
	ID                   string     `json:"id"`
	StackName            string     `json:"stack_name"`
	StartedAt            time.Time  `json:"started_at"`
	FinishedAt           *time.Time `json:"finished_at,omitempty"`
	Status               RunStatus  `json:"status"`
	Label                string     `json:"label,omitempty"`
	StopMode             string     `json:"stop_mode,omitempty"`
	Verified             *bool      `json:"verified,omitempty"`
	RepoSizeBytes        uint64     `json:"repo_size_bytes,omitempty"`
	SizeBytes            uint64     `json:"size_bytes"`
	AddedBytes           uint64     `json:"added_bytes"`
	ComponentCount       int        `json:"component_count"`
	ComponentsWithErrors int        `json:"components_with_errors"`
}

func SummariseRun

func SummariseRun(run *Run) RunSummary

type Service

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

func NewService

func NewService(cfg *config.Config, logger *logging.Logger, dockerClient *docker.Client, commandExec *docker.CommandExecutor, stacks stackLister) (*Service, error)

func NewServiceWithConfig

func NewServiceWithConfig(cfg *config.Config, logger *logging.Logger, dockerClient *docker.Client, stacks *stack.Service) (*Service, error)

func (*Service) ArchiveBackupFiles

func (s *Service) ArchiveBackupFiles(ctx context.Context, stackName, backupID, componentID string, relPaths []string, password string, out io.Writer) error

func (*Service) BuildOverview

func (s *Service) BuildOverview() (*Overview, error)

func (*Service) Configured

func (s *Service) Configured() bool

func (*Service) CreateBackup

func (s *Service) CreateBackup(ctx context.Context, stackName, stackPath string, opts CreateOptions, writer ProgressWriter) error

func (*Service) DeleteBackup

func (s *Service) DeleteBackup(ctx context.Context, stackName, backupID, password string) error

func (*Service) DumpBackupFile

func (s *Service) DumpBackupFile(ctx context.Context, stackName, backupID, componentID, relPath, password string, out io.Writer) error

func (*Service) GetRun

func (s *Service) GetRun(stackName, runID string) (*Run, error)

func (*Service) ListBackupFiles

func (s *Service) ListBackupFiles(ctx context.Context, stackName, backupID, componentID, relPath, password string) (*FileListing, error)

func (*Service) ListRunSummaries

func (s *Service) ListRunSummaries(stackName string, limit, offset int) (int, []RunSummary, error)

func (*Service) MarkInterruptedRuns

func (s *Service) MarkInterruptedRuns()

func (*Service) RemoveOrphanedHelpers

func (s *Service) RemoveOrphanedHelpers(ctx context.Context)

func (*Service) RestoreBackup

func (s *Service) RestoreBackup(ctx context.Context, stackName, stackPath string, opts RestoreOptions, writer ProgressWriter) error

func (*Service) StatBackupFiles

func (s *Service) StatBackupFiles(ctx context.Context, stackName, backupID, componentID string, relPaths []string, password string) ([]FileEntry, error)

type SkippedMount

type SkippedMount struct {
	Kind    string `json:"kind"`
	Service string `json:"service,omitempty"`
	Target  string `json:"target,omitempty"`
	Reason  string `json:"reason"`
}

type StackBackupSummary

type StackBackupSummary struct {
	StackName     string      `json:"stack_name"`
	StackExists   bool        `json:"stack_exists"`
	RunCount      int         `json:"run_count"`
	LatestRun     *RunSummary `json:"latest_run,omitempty"`
	RepoSizeBytes uint64      `json:"repo_size_bytes,omitempty"`
}

type VolumeDefinition

type VolumeDefinition struct {
	External   bool              `json:"external,omitempty"`
	Driver     string            `json:"driver,omitempty"`
	DriverOpts map[string]string `json:"driver_opts,omitempty"`
	Labels     map[string]string `json:"labels,omitempty"`
}

Jump to

Keyboard shortcuts

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