backups

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package backups owns the v1.12 phase 8 backup/restore workflow.

SQLite: SQL `VACUUM INTO 'path'` writes a consistent snapshot to a fresh file on disk. The file is portable — operators copy it off-host for archival.

Postgres: shell out to `pg_dump` with the daemon's DSN. The binary must be on PATH; the daemon process must have permission to write to the configured backup directory. Restore is a manual `pg_restore` step documented in OPERATIONS.md — too destructive to expose as a one-click UI affordance.

The catalog table (backups) is the index — every Create records one row with the path + size + kind so the operator can pick which one to restore from.

Index

Constants

View Source
const (
	KindSQLite   = "sqlite"
	KindPostgres = "postgres"
)

Kind names the backup format.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	ID          string
	CreatedAt   time.Time
	Kind        string // "sqlite" or "postgres"
	Path        string
	SizeBytes   int64
	Status      string // "ok", "failed", "in_progress"
	Note        string
	TriggeredBy string
}

Backup is the in-memory shape of one catalog row.

type Manager

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

Manager wraps the catalog + the on-disk dump operations.

func New

func New(st *store.Store, dir, dsn string) *Manager

New returns a Manager bound to st with backups landing under dir. dsn is the Postgres connection string when st is Postgres-backed; ignored for SQLite.

func (*Manager) ByID

func (m *Manager) ByID(ctx context.Context, id string) (*Backup, error)

ByID returns the catalog row for id.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, note, triggeredBy string) (*Backup, error)

Create dumps the daemon's database into m.dir. Returns the Backup row recorded in the catalog. note is a free-form operator label (e.g. "pre-v1.12-upgrade"); triggeredBy is the user ID — empty for scheduled / automatic backups.

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, id string) error

Delete removes a backup catalog row + its on-disk dump file. Best- effort on the file; the row deletion is the source of truth.

func (*Manager) Dir

func (m *Manager) Dir() string

Dir returns the backup directory.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]*Backup, error)

List returns every catalog row, newest first.

Jump to

Keyboard shortcuts

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