backup

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 17 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 database dump shared by every worktree of a project.

Index

Constants

View Source
const (

	// RestoreScriptName is the docker-entrypoint-initdb.d script each worktree
	// reaches through its .db-snapshot link.
	RestoreScriptName = "restore-snapshot.sh"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

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

type Manager

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

func (*Manager) Check

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

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

func (Staleness) Describe

func (s Staleness) Describe() string

Jump to

Keyboard shortcuts

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