Documentation
¶
Overview ¶
Package backup produces and manages the pre-migrated Postgres dump shared by every worktree of a project.
Index ¶
- type Info
- type Manager
- func (m *Manager) Check(ctx context.Context, name string, p config.Project) Staleness
- func (m *Manager) DumpPath(name string) string
- func (m *Manager) List(cfg *config.Config) ([]Info, error)
- func (m *Manager) MetaPath(name string) string
- func (m *Manager) ReadMeta(name string) (Meta, error)
- func (m *Manager) Refresh(ctx context.Context, name string, p config.Project) error
- func (m *Manager) Remove(name string) (bool, error)
- type Meta
- type Staleness
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
Check compares the revision recorded next to the dump with the project's migration history.
func (*Manager) Refresh ¶
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.
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.