backup

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package backup produces and manages the pre-migrated Postgres dump shared by every worktree of a project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Name    string
	Present bool
	Size    int64
	Meta    Meta
}

Info is one line of `backup list`.

type Manager

type Manager struct {
	Runner          execx.Runner
	Root            string
	Out             io.Writer
	MaxWaitAttempts int
	WaitInterval    time.Duration
}

Manager owns the central backups directory.

func (*Manager) Check

func (m *Manager) Check(ctx context.Context, name string, p config.Project) Staleness

Check compares the revision recorded next to the dump with the project's migration history.

func (*Manager) DumpPath

func (m *Manager) DumpPath(name string) string

func (*Manager) List

func (m *Manager) List(cfg *config.Config) ([]Info, error)

List reports every project that has, or is expected to have, a backup.

func (*Manager) MetaPath

func (m *Manager) MetaPath(name string) string

func (*Manager) ReadMeta

func (m *Manager) ReadMeta(name string) (Meta, error)

func (*Manager) Refresh

func (m *Manager) Refresh(ctx context.Context, name string, p config.Project) error

Refresh regenerates the dump: it starts the database if needed, migrates a throwaway one and dumps it as migrate left it, data included. Everything the migrations create is therefore captured, permissions and reference data among them; only what they did not create, seed data first of all, is out.

func (*Manager) Remove

func (m *Manager) Remove(name string) (bool, error)

Remove deletes the dump and its metadata. Removing an absent backup is not an error; the boolean says whether anything was actually deleted.

type Meta

type Meta struct {
	GeneratedAt time.Time `json:"generated_at"`
	GeneratedBy string    `json:"generated_by"`
	GitRev      string    `json:"git_rev"`
}

Meta travels next to the dump so `backup list` can say where it comes from.

type Staleness

type Staleness struct {
	Commits int  // commits touching migrations since the dump was taken
	Known   bool // false when the recorded revision cannot be compared
}

Staleness says how far a dump has fallen behind the migrations it was built from. A stale dump still works, the application simply replays the delta on startup, so this is worth reporting and never worth blocking on.

func (Staleness) Behind

func (s Staleness) Behind() bool

Behind reports whether refreshing would save time.

func (Staleness) Describe

func (s Staleness) Describe() string

Describe renders the state for a listing.

Jump to

Keyboard shortcuts

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