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 ¶
- type Record
- type Store
- func (s *Store) Available() bool
- func (s *Store) BackedUpVolumes(ctx context.Context) (map[string]bool, error)
- func (s *Store) Catalog(ctx context.Context, rec Record) error
- func (s *Store) Create(ctx context.Context, now time.Time) (Record, error)
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) Dir() string
- func (s *Store) FilePath(r Record) string
- func (s *Store) Get(ctx context.Context, id string) (Record, bool, error)
- func (s *Store) List(ctx context.Context) ([]Record, error)
- func (s *Store) NewID() (string, error)
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 (*Store) Available ¶
Available reports whether backups can be taken (a valid key is configured).
func (*Store) BackedUpVolumes ¶ added in v0.6.0
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
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 ¶
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 ¶
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
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 ¶
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).