scheduledbackup

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package scheduledbackup provides scheduled PostgreSQL backups with pg_dump. It supports cron-based scheduling and manual backup via HTTP API and CLI commands, and records backup history in PostgreSQL. Dumps are written to local disk only -- there is no restore path and no off-host upload.

Package scheduledbackup provides scheduled PostgreSQL backups with pg_dump. It supports cron-based scheduling and manual backup via HTTP API and CLI commands, and records backup history in PostgreSQL. Dumps are written to local disk (Config.DumpDir) only -- there is no restore path and no off-host upload; see the s3_bucket/s3_prefix doc comments on backupConfig in routes.go before relying on either.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() plugin.Plugin

New creates a new Plugin instance.

Types

type Config

type Config struct {
	// DSN is the PostgreSQL connection string pg_dump backs up. It commonly
	// embeds a password, so it is a plugin.Secret: never marshaled in the
	// clear, and passed to pg_dump via runPgDump (background.go), which
	// puts any password in the child process's PGPASSWORD environment
	// variable rather than its argv -- argv is visible to any co-resident
	// user via ps and /proc/*/cmdline, unlike the environment of a process
	// you do not own.
	DSN     plugin.Secret `json:"dsn"`
	DumpDir string        `json:"dump_dir"` // Directory for dump output files
}

Config controls backup storage and pg_dump output location.

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin implements scheduled PostgreSQL backups with tenant isolation.

func (*Plugin) Info

func (p *Plugin) Info() plugin.PluginInfo

Info returns plugin metadata for discovery and documentation.

func (*Plugin) Init

func (p *Plugin) Init(ctx context.Context, env *plugin.Environment) error

Init initializes the plugin with the given environment.

func (*Plugin) Migrations

func (p *Plugin) Migrations() []plugin.Migration

Migrations returns the database schema for backup configuration and history. Tables are idempotent (IF NOT EXISTS) and safe to run multiple times.

func (*Plugin) RegisterCommands

func (p *Plugin) RegisterCommands() []plugin.Command

RegisterCommands returns CLI subcommands for the scheduled-backup plugin.

func (*Plugin) RegisterRoutes

func (p *Plugin) RegisterRoutes(mux *http.ServeMux) error

func (*Plugin) Run

func (p *Plugin) Run(ctx context.Context) error

Run starts the background backup scheduler loop. Every 60 seconds it queries the backup_config table for enabled configs whose next_run_at <= now() and executes pg_dump for each due backup. Returns when ctx is cancelled.

Jump to

Keyboard shortcuts

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