Documentation
¶
Overview ¶
Package backup provides database backup and restore utilities for goent.
It supports two database backends:
- SQLite: full backups by copying the database file.
- PostgreSQL: full backups using pg_dump schema + COPY data, and incremental backups using JSON Lines for rows changed since a base time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Dir is the directory where backup archives are stored.
// If empty, the current working directory is used.
Dir string
// DSN is the database connection string used by external tools such as
// pg_dump, psql, and for locating the SQLite database file.
DSN string
// DBPath is the explicit SQLite database file path. If empty, the engine
// attempts to derive it from DSN.
DBPath string
// Schema is the PostgreSQL schema to back up. Defaults to "public".
Schema string
// LogTables are tables whose data should not be backed up.
// Only structure is preserved for these tables.
LogTables []string
// ExcludedFromIncremental are tables that should be skipped in incremental
// backups. Usually this includes log tables and the backup metadata table.
ExcludedFromIncremental []string
}
Config customizes backup and restore behaviour.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine creates and restores database backups.
func (*Engine) Full ¶
Full creates a full backup archive and returns its metadata.
For SQLite this copies the database file. For PostgreSQL it dumps the schema and exports each non-log table with COPY.
func (*Engine) Incremental ¶
Incremental creates an incremental backup archive containing rows changed since the provided base time. The caller is responsible for choosing the correct base time, typically the started time of the last successful full backup.
Click to show internal directories.
Click to hide internal directories.