backupsched

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package backupsched is the scheduled app-data backup loop. On a fixed interval it discovers every app's docker DATA VOLUMES and snapshots each one — a read-only tar of the volume, streamed through gzip + AES-256-GCM (internal/appbackup) into a local .mbk and, when an S3 destination is configured, uploaded off-box. Old snapshots beyond the retention count are pruned (local file + catalog row + remote object).

It rides the existing write-plane one-docker-child semaphore via TryAcquire (skip-don't- queue — never queue a docker child; a backup that can't get the slot this cycle retries the next), so a backup never competes with or delays a deploy/self-heal. Volume snapshots are engine-agnostic and safe for every stateful service (Postgres, MySQL, Redis, Mongo, …); logical DB dumps (appbackup's pg_dump/mysqldump path) are a future per-service refinement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval    time.Duration
	Retention   int
	HelperImage string
	Key         []byte // 32-byte master key
	EnvFileDir  string // 0700 dir for transient credential env-files (unused for volume tars)
	S3Prefix    string // optional key prefix for uploads
}

Config is the resolved backup policy.

type Runner

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

Runner is the scheduled backup loop.

func New

func New(run StreamRunner, sem Semaphore, cat *backupstore.Store, apps func() []string, s3 Uploader, cfg Config, alert func(level, title, detail string), log *slog.Logger) *Runner

New builds a Runner. s3 may be nil (local-only). alert may be nil.

func (*Runner) BackupAll

func (r *Runner) BackupAll(ctx context.Context)

BackupAll snapshots every data volume of every app, one at a time.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context)

Run backs up a few minutes after boot (let the box settle), then every interval, until ctx is done.

type Semaphore

type Semaphore interface {
	TryAcquire() bool
	Release()
}

Semaphore is the one-docker-child gate (satisfied by dockerexec.Semaphore).

type StreamRunner

type StreamRunner interface {
	RunStreamHeld(ctx context.Context, argv []string, stdout io.Writer, onErrLine func(string)) error
}

StreamRunner runs a static-argv docker command (satisfied by dockerexec.Runner). The caller of RunStreamHeld must hold the one-docker-child semaphore. Its method set matches appbackup.StreamRunner, so a StreamRunner value passes straight to appbackup.Produce.

type Uploader

type Uploader interface {
	Put(ctx context.Context, key string, r io.Reader, size int64, contentType string) error
	Delete(ctx context.Context, key string) error
}

Uploader is the optional off-box destination (satisfied by s3.Client).

Jump to

Keyboard shortcuts

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