backupstore

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Overview

Package backupstore manages Mooring's own-state backups: a consistent snapshot of the SQLite database (via VACUUM INTO), AES-256-GCM-encrypted with the master key (the chunked, tamper-evident stream from internal/backup), written under the data dir and recorded in a catalog. This is the "recover Mooring onto a fresh box" backup — it carries every app's config, definitions, edge routes, and (already- encrypted) secrets. App-internal data volumes are a separate snapshot type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	ID        string
	CreatedAt int64
	SizeBytes int64
	File      string
	SHA256    string
	Kind      string // "mooring-state" | "postgres" | "mysql" | "volume"
	Note      string
	Project   string // app slug ("" for mooring-state)
	Target    string // service (db dump) or volume name ("" for mooring-state)
	Location  string // "local" | "s3" | "local+s3"
}

Record is one catalogued backup.

type Store

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

Store creates, lists, and deletes encrypted state backups.

func New

func New(db *store.DB, dir string, key []byte) *Store

New builds a Store. dir is where archives are written (created 0700 on first use).

func (*Store) Available

func (s *Store) Available() bool

Available reports whether backups can be taken (a valid key is configured).

func (*Store) BackedUpVolumes added in v0.6.0

func (s *Store) BackedUpVolumes(ctx context.Context) (map[string]bool, error)

BackedUpVolumes returns the set of docker volumes that have a recorded backup (feeds backup.LiveState.BackedUpVolumes so PruneVolumeSafe won't drop an un-backed-up sole volume).

func (*Store) Catalog added in v0.6.0

func (s *Store) Catalog(ctx context.Context, rec Record) error

Catalog records an already-produced+encrypted backup file (an app-data snapshot from the appbackup engine). The file must already exist under Dir() as <rec.ID>.mbk; rec carries the size/sha the engine computed while streaming. For a volume backup it also updates backup_inventory so the prune denylist knows the volume is backed up.

func (*Store) Create

func (s *Store) Create(ctx context.Context, now time.Time) (Record, error)

Create takes a consistent snapshot of the DB, encrypts it, and records it. The plaintext snapshot exists only transiently (0600, in the 0700 backups dir) and is removed as soon as it's encrypted.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

Delete removes the archive file and the catalog row, and keeps backup_inventory truthful. NOTE: for a volume snapshot that was also uploaded off-box (Location contains "s3"), the REMOTE object is not removed here (this store has no uploader) — scheduled retention prunes S3 copies; a manual delete of an app-data backup leaves its S3 copy for now.

func (*Store) Dir added in v0.6.0

func (s *Store) Dir() string

Dir returns the backups directory (0700). The app-data backup engine writes its externally-produced .mbk here (see appbackup.LocalFile) and then calls Catalog.

func (*Store) FilePath

func (s *Store) FilePath(r Record) string

FilePath returns the absolute path of a record's archive, confined to the backups dir (the stored file name is always a generated <id>.mbk, never user input).

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (Record, bool, error)

Get returns one record by id (ok=false if absent/malformed).

func (*Store) List

func (s *Store) List(ctx context.Context) ([]Record, error)

List returns catalogued backups, newest first.

func (*Store) NewID added in v0.6.0

func (s *Store) NewID() (string, error)

NewID allocates a fresh 24-hex backup id.

Jump to

Keyboard shortcuts

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