
backup-activities
Index
- type Activities
- func New(cfg Config) (*Activities, error)
- func (a *Activities) BackupPostgresDatabase(ctx context.Context, database string) (string, error)
- func (a *Activities) BackupPostgresGlobals(ctx context.Context) (string, error)
- func (a *Activities) CleanupOldBackups(ctx context.Context, retentionDays int) error
- func (a *Activities) CleanupOldS3Backups(ctx context.Context, retentionDays int) error
- func (a *Activities) ListPostgresDatabases(ctx context.Context) ([]string, error)
- func (a *Activities) TakeConsulSnapshot(ctx context.Context) (string, error)
- func (a *Activities) TakeNomadSnapshot(ctx context.Context) (string, error)
- func (a *Activities) TakeRegistryBackup(ctx context.Context) (string, error)
- func (a *Activities) UploadToS3(ctx context.Context, localPath string, keyPrefix string) (string, error)
- type BackupConfig
- type BackupResult
- type Config
- type DatabaseBackup
type Activities
Activities holds shared dependencies for backup activities. Register an instance with the Temporal worker to expose all exported methods as activity implementations.
func New
New creates an Activities instance with a pre-configured S3 client. Returns an error if the config is invalid.
func (*Activities) BackupPostgresDatabase
BackupPostgresDatabase dumps a single database to its own gzipped file. Smaller per-database files restore faster and spread across storage more evenly than one cluster-wide dump. Long-running for large databases, so it heartbeats while the dump runs. Requires PGPASSWORD in the environment.
func (*Activities) BackupPostgresGlobals
BackupPostgresGlobals dumps cluster-wide objects (roles, tablespaces, and grants) that per-database pg_dump does not capture. Without this, a full-cluster restore would come up with no roles or permissions. Requires PGPASSWORD in the environment.
func (*Activities) CleanupOldBackups
CleanupOldBackups removes local backup files older than the retention period across all backup directories.
func (*Activities) CleanupOldS3Backups
CleanupOldS3Backups removes S3 backup objects older than the retention period by listing all objects under the backups/ prefix and deleting those whose LastModified exceeds the cutoff.
func (*Activities) ListPostgresDatabases
ListPostgresDatabases returns the names of all non-template, connectable databases in the cluster. The workflow fans these out into per-database dumps. Requires PGPASSWORD in the environment.
func (*Activities) TakeConsulSnapshot
TakeConsulSnapshot creates a Raft snapshot of the Consul cluster state including KV store, service catalog, ACLs, sessions, and intentions. Vault data is included since Vault uses Consul as its storage backend. Requires CONSUL_HTTP_TOKEN with snapshot permissions in the environment.
func (*Activities) TakeNomadSnapshot
TakeNomadSnapshot creates a Raft snapshot of the Nomad cluster state including job specs, allocations, ACLs, and scheduler configuration. Requires NOMAD_TOKEN with snapshot permissions in the environment.
func (*Activities) TakeRegistryBackup
TakeRegistryBackup creates a gzipped tarball of the container registry data directory including all pushed images, layers, manifests, and metadata.
func (*Activities) UploadToS3
UploadToS3 uploads a local backup file to S3 storage. The S3 key is constructed from the prefix and the original filename. If the upload fails with a 507 quota error, the oldest backup under the same prefix is evicted and the upload is retried up to 3 times.
type BackupConfig
BackupConfig holds workflow-level configuration passed as input so values are deterministic across replays.
func (*BackupConfig) ApplyDefaults
ApplyDefaults fills in unset fields with their defaults. Called by the workflow before any activities run so the values are deterministic across replay.
type BackupResult
BackupResult contains the outcome of a backup workflow execution. The PostgreSQL leg now produces one dump per database (plus a globals dump) rather than a single cluster-wide file.
type Config
Config holds environment-driven settings for backup activities.
func (*Config) Validate
Validate checks that required S3 fields are present and applies defaults for optional directory paths.
type DatabaseBackup
DatabaseBackup records the outcome of backing up a single PostgreSQL database: the local dump path and, if the upload succeeded, its S3 key.
Generated by gomarkdoc