Documentation
¶
Overview ¶
Package backup creates integrity-checked, portable snapshots without copying live WAL files.
On SQLite a snapshot holds a VACUUM INTO copy (ether.db). On PostgreSQL, where file copies do not apply, it holds a logical dump of every table (database.jsonl, see store.ExportLogical) and the manifest records dialect "postgres"; a restored dump is imported into an empty database on the next start (ImportPending).
Index ¶
- Constants
- func FilesystemWarning(ctx context.Context, dataDir string) string
- func ImportPending(ctx context.Context, db *sql.DB, dataDir string) (bool, error)
- func RestoreBundle(ctx context.Context, r io.Reader, destination string) error
- type Manifest
- type Node
- type Service
- func (s *Service) Configure(ctx context.Context, v Settings) error
- func (s *Service) Create(ctx context.Context) (Snapshot, error)
- func (s *Service) Handler() http.Handler
- func (s *Service) List() ([]Snapshot, error)
- func (s *Service) Run(ctx context.Context, onError func(error))
- func (s *Service) SetCluster(n Node)
- func (s *Service) Settings(ctx context.Context) (Settings, error)
- func (s *Service) Snapshots(ctx context.Context) ([]Snapshot, error)
- type Settings
- type Snapshot
Constants ¶
const LogicalDumpFile = "database.jsonl"
LogicalDumpFile is the PostgreSQL bundle's database entry. Left in a data directory by a restore, it is imported into the (empty) database at start.
Variables ¶
This section is empty.
Functions ¶
func FilesystemWarning ¶
FilesystemWarning detects the mount containing dataDir on Linux and macOS.
func ImportPending ¶
ImportPending imports a restored logical dump (LogicalDumpFile in dataDir) into db, which must be freshly migrated and empty, then renames the dump so it is imported only once. It reports whether it imported.
Types ¶
type Node ¶
type Node struct {
ID, Name string
}
Node identifies the cluster node a Service runs on.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) SetCluster ¶
SetCluster marks the server as clustered: every bundle is recorded in the shared database with the node that holds it (so any node lists the whole cluster's backups), and the shared backup directory setting is honoured. A standalone server never calls it and keeps its bundles in its data directory only.
type Settings ¶
type Settings struct {
IntervalHours int `json:"intervalHours"`
Retain int `json:"retain"`
LastRun int64 `json:"lastRun"`
// at the same path, where scheduled and manual backups are written
// instead of the writing node's data directory. Empty keeps them on
// the node that made them.
SharedDir string `json:"sharedDir,omitempty"`
}
type Snapshot ¶
type Snapshot struct {
Name string `json:"name"`
Size int64 `json:"size"`
Created time.Time `json:"created"`
// Clustered servers only: the node that wrote the bundle and holds it
// (unless Shared), whether it is in the shared backup directory, and
// Remote when it is on another node's disk (download it there).
Node string `json:"node,omitempty"`
NodeID string `json:"nodeId,omitempty"`
Remote bool `json:"remote,omitempty"`
}