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.
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.