backup

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: GPL-2.0 Imports: 33 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 ErrInvalidS3Repository = errors.New("invalid s3 repository")
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 AbandonBackupStorageResult added in v0.5.2

type AbandonBackupStorageResult struct {
	Complete bool         `json:"complete"`
	Before   HistoryState `json:"before"`
	After    HistoryState `json:"after"`
	Errors   []string     `json:"errors"`
}

type BackupPruneStatus added in v0.5.2

type BackupPruneStatus string
const (
	BackupPruneNotNeeded    BackupPruneStatus = "not_needed"
	BackupPruneNotAttempted BackupPruneStatus = "not_attempted"
	BackupPruneSucceeded    BackupPruneStatus = "succeeded"
	BackupPruneFailed       BackupPruneStatus = "failed"
)

type BrowseRequest added in v0.5.2

type BrowseRequest struct {
	BackupPassword string        `json:"backup_password"`
	Repository     *S3Repository `json:"s3_repository,omitempty"`
}

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
	Repository *S3Repository
}

type DeleteAllBackupsRequest added in v0.5.2

type DeleteAllBackupsRequest struct {
	BackupPassword   string        `json:"backup_password"`
	S3RepositoryBase *S3Repository `json:"s3_repository_base,omitempty"`
}

type DeleteAllBackupsResult added in v0.5.2

type DeleteAllBackupsResult struct {
	Complete bool                       `json:"complete"`
	Before   HistoryState               `json:"before"`
	After    HistoryState               `json:"after"`
	Stacks   []DeleteStackBackupsResult `json:"stacks"`
	Errors   []string                   `json:"errors"`
}

type DeleteBackupRequest

type DeleteBackupRequest struct {
	BackupPassword string        `json:"backup_password"`
	Repository     *S3Repository `json:"s3_repository,omitempty"`
}

type DeleteStackBackupsResult added in v0.5.2

type DeleteStackBackupsResult struct {
	StackName          string            `json:"stack_name"`
	Attempted          bool              `json:"attempted"`
	RecordsBefore      int               `json:"records_before"`
	RecordsDeleted     int               `json:"records_deleted"`
	RecordsRemaining   int               `json:"records_remaining"`
	SnapshotsForgotten int               `json:"snapshots_forgotten"`
	PruneStatus        BackupPruneStatus `json:"prune_status"`
	Errors             []string          `json:"errors"`
}

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) AbandonBackupStorage added in v0.5.2

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

func (*Handler) DeleteAllBackups added in v0.5.2

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

func (*Handler) DeleteStackBackup

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

func (*Handler) DownloadBackupFiles

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

func (*Handler) GetBackupHistory added in v0.5.2

func (h *Handler) GetBackupHistory(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

func (*Handler) RebuildStackIndex added in v0.5.2

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

type HistoryState added in v0.5.2

type HistoryState struct {
	Empty                 bool `json:"empty"`
	StackCount            int  `json:"stack_count"`
	RecordCount           int  `json:"record_count"`
	UnreadableRecordCount int  `json:"unreadable_record_count"`
}

type ListBackupsResponse

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

type OperationReservation added in v0.5.2

type OperationReservation interface {
	CreateBackup(context.Context, string, string, CreateOptions, ProgressWriter) error
	RestoreBackup(context.Context, string, string, RestoreOptions, ProgressWriter) error
	Release()
}

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 RebuildRequest added in v0.5.2

type RebuildRequest struct {
	BackupPassword string        `json:"backup_password"`
	Repository     *S3Repository `json:"s3_repository,omitempty"`
}

type RebuildResult added in v0.5.2

type RebuildResult struct {
	RunsInRepository int      `json:"runs_in_repository"`
	RunsAdded        int      `json:"runs_added"`
	Output           []string `json:"output"`
}

type RestoreOptions

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

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 S3Repository added in v0.5.2

type S3Repository struct {
	URL         string `json:"url"`
	AccessKeyID string `json:"access_key_id"`
	SecretKey   string `json:"secret_access_key"`
	Region      string `json:"region,omitempty"`
}

func (*S3Repository) Validate added in v0.5.2

func (r *S3Repository) Validate() error

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) AbandonBackupStorage added in v0.5.2

func (s *Service) AbandonBackupStorage(ctx context.Context) (AbandonBackupStorageResult, error)

func (*Service) ArchiveBackupFiles

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

func (*Service) BackupHistory added in v0.5.2

func (s *Service) BackupHistory() (HistoryState, 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) DeleteAllBackups added in v0.5.2

func (s *Service) DeleteAllBackups(ctx context.Context, password string, s3RepositoryBase *S3Repository) (DeleteAllBackupsResult, error)

func (*Service) DeleteBackup

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

func (*Service) DumpBackupFile

func (s *Service) DumpBackupFile(ctx context.Context, stackName, backupID, componentID, relPath, password string, s3Repo *S3Repository, 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, s3Repo *S3Repository) (*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) RebuildIndex added in v0.5.2

func (s *Service) RebuildIndex(ctx context.Context, stackName, password string, s3Repo *S3Repository, writer ProgressWriter) (RebuildResult, error)

func (*Service) RemoveOrphanedHelpers

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

func (*Service) ReserveOperation added in v0.5.2

func (s *Service) ReserveOperation() (OperationReservation, error)

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, s3Repo *S3Repository) ([]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