activities

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Package activities defines the activities executed by the client backup agent.

Index

Constants

View Source
const ErrTypeBackupFailed = "backup_failed"

ErrTypeBackupFailed marks a failed (but retryable) backup activity; the error carries temporal.BackupFailureDetails for the workflow.

View Source
const ErrTypeDBPrecheckFailed = "db_precheck_failed"

ErrTypeDBPrecheckFailed marks configuration/precheck failures of database backups; the workflow does not retry them.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentActivities

type AgentActivities struct {
	// Tunnel is the agent's gRPC connection to the FallBCK server (carrying its bearer
	// token); PBS backup sessions are opened through it.
	Tunnel grpc.ClientConnInterface
	// Workers bounds concurrent chunk uploads (0 = default)
	Workers int
	// Credentials fetches PBS connection details for jobs in direct mode
	// (GET /api/v1/agents/pbs-credentials with the run's ticket)
	Credentials func(ctx context.Context, ticket string) (*backup.DirectOptions, error)
	// EncryptionKey fetches the target's client-side encryption key for a run
	// (GET /api/v1/agents/encryption-key with the run's ticket)
	EncryptionKey KeyFetcher
	// RefreshTicket re-issues the run's ticket with a fresh snapshot timestamp for
	// retries (POST /api/v1/agents/ticket/refresh); nil keeps the session's timestamp
	RefreshTicket TicketRefreshFunc
	// LogTail returns the agent's recent log output, attached to failures
	LogTail func() string
	// ReportProgress posts live phase updates to the server (best-effort)
	ReportProgress ProgressFunc
	// SpoolDir stages collected data for Proxmox VE and Docker host backups (<data dir>/spool)
	SpoolDir string
	// Docker is the agent's docker_backup settings block (socket, volume access, helper image)
	Docker dockerspec.Config
	// M365Credentials fetches the tenant credentials of a Microsoft 365 job
	// (GET /api/v1/agents/m365-credentials with the run's ticket)
	M365Credentials func(ctx context.Context, ticket string) (*m365.Credentials, error)
	// SubTicket mints the ticket of one unit snapshot of a run (POST
	// /api/v1/agents/sub-ticket): the unit's group must extend the run's group
	SubTicket func(ctx context.Context, sessionTicket, group string) (ticket string, backupTime int64, err error)
	// M365StateDir holds the per-job unit indexes of Microsoft 365 jobs (<data dir>/m365-state)
	M365StateDir string
	// CacheDir holds the per-group metadata caches for change detection
	// (<data dir>/pxar-cache); empty disables change detection
	CacheDir string
	// VSSDir enables Volume Shadow Copies on Windows: paths are read through
	// shadow copies linked under this directory; empty reads the live filesystem
	VSSDir   string
	Hostname string
	Version  string
}

AgentActivities provides activities executed on the client backup agent host

func NewAgentActivities

func NewAgentActivities() *AgentActivities

NewAgentActivities creates a new AgentActivities instance

func (*AgentActivities) ExecuteDockerBackup added in v0.9.11

ExecuteDockerBackup backs up the Docker host this agent runs on: container, network, volume and image definitions, compose files and the daemon configuration (collect/) plus every named volume (vol-<name>) go into one docker.pxar archive.

func (*AgentActivities) ExecuteFilesystemBackup

func (a *AgentActivities) ExecuteFilesystemBackup(ctx context.Context, session *temporal.BackupSessionInfo) (*temporal.BackupExecutionResult, error)

ExecuteFilesystemBackup performs the filesystem backup on the agent host, streaming into PBS through the server-side tunnel.

func (*AgentActivities) ExecuteM365Backup added in v0.14.0

ExecuteM365Backup backs up a Microsoft 365 tenant: one snapshot per user, site and team (each with its own sub-ticket and PBS session) plus the directory snapshot in the job's own group, which carries the run manifest.

func (*AgentActivities) ExecutePVEBackup added in v0.9.5

ExecutePVEBackup backs up the Proxmox VE host this agent runs on: the collected inventory (/etc/pve copy, package lists, storage/network/disk definitions, restore runbook), /etc, /root and the job's data paths go into one pve.pxar archive.

type AgentOpsActivities added in v0.12.0

type AgentOpsActivities struct {
	// LogTail returns the agent's recent log output (the in-memory ring)
	LogTail func() string
	// LogLevel names the current log level for the logs answer
	LogLevel func() string
	// Detail builds the full inventory (nil: only the summary parts are known)
	Detail func(ctx context.Context) *inventory.Detail
}

AgentOpsActivities are the operator actions of the agent status page, run on the agent's own task queue like backups: the recent log lines and the full inventory. Every agent binary registers one; the inventory collector is per agent type.

func (*AgentOpsActivities) GetAgentInventory added in v0.12.0

func (a *AgentOpsActivities) GetAgentInventory(ctx context.Context) (*inventory.Detail, error)

GetAgentInventory builds and returns the full inventory

func (*AgentOpsActivities) GetAgentLogs added in v0.12.0

func (a *AgentOpsActivities) GetAgentLogs(ctx context.Context) (*inventory.LogsResult, error)

GetAgentLogs returns the agent's recent log lines

type DBAgentActivities added in v0.6.0

type DBAgentActivities struct {
	// Tunnel is the agent's gRPC connection to the FallBCK server (PBS sessions)
	Tunnel grpc.ClientConnInterface
	// Workers bounds concurrent chunk uploads (0 = default)
	Workers int
	// Credentials fetches PBS connection details for jobs in direct mode
	Credentials func(ctx context.Context, ticket string) (*backup.DirectOptions, error)
	// EncryptionKey fetches the target's client-side encryption key for a run
	// (GET /api/v1/agents/encryption-key with the run's ticket)
	EncryptionKey KeyFetcher
	// DBPassword fetches the server-stored database password for a run
	DBPassword func(ctx context.Context, ticket string) (string, error)
	// RefreshTicket re-issues the run's ticket with a fresh snapshot timestamp for
	// retries; nil keeps the session's timestamp
	RefreshTicket TicketRefreshFunc
	// Config is the agent's db_backup configuration (defaults applied)
	Config   dbbackup.Config
	Hostname string
	Version  string
	// LogTail returns the agent's recent log output, attached to failures
	LogTail func() string
	// ReportProgress posts live phase updates to the server (best-effort)
	ReportProgress ProgressFunc
}

DBAgentActivities are the database backup activities, registered by fallbck-agent next to its filesystem activities (agents of the retired type "database" that are still running their old binary poll the same activity name on their own queue)

func NewDBAgentActivities added in v0.6.0

func NewDBAgentActivities() *DBAgentActivities

NewDBAgentActivities creates a new DBAgentActivities instance

func (*DBAgentActivities) ExecuteDatabaseBackup added in v0.6.0

func (a *DBAgentActivities) ExecuteDatabaseBackup(ctx context.Context, session *temporal.BackupSessionInfo) (*temporal.BackupExecutionResult, error)

ExecuteDatabaseBackup dumps the job's databases into the spool directory and uploads the result to PBS (through the server tunnel or directly).

type K8sAgentActivities added in v0.7.2

type K8sAgentActivities struct {
	// Tunnel is the agent's gRPC connection to the FallBCK server (resources upload)
	Tunnel grpc.ClientConnInterface
	// Clients are the in-cluster API clients
	Clients *k8sagent.Clients
	// Config supplies the server URL / TLS settings handed to worker pods
	Config      *config.AgentConfig
	ClusterName string
	// AgentNamespace is the namespace the agent pod runs in
	AgentNamespace string
	Version        string
	// Worker pod parameters (from the Helm chart)
	WorkerImage               string
	WorkerImagePullPolicy     string
	WorkerResourcesJSON       string
	WorkerSecurityContextJSON string
	// WorkerMaxProcs bounds gopbs concurrency (GOMAXPROCS) inside worker pods; 0 = 2
	WorkerMaxProcs int
	// Credentials fetches PBS connection details for jobs in direct mode
	Credentials func(ctx context.Context, ticket string) (*backup.DirectOptions, error)
	// EncryptionKey fetches the target's client-side encryption key for a run
	// (GET /api/v1/agents/encryption-key with the run's ticket)
	EncryptionKey KeyFetcher
	// VolumeTicket mints a per-volume backup ticket from the session ticket; the
	// returned snapshot timestamp is the one embedded in the ticket (fresh per attempt)
	VolumeTicket func(ctx context.Context, sessionTicket, volumeBackupID string) (ticket string, backupTime int64, err error)
	// WorkerToken mints a short-lived agent bearer for worker pods
	WorkerToken func(ctx context.Context, sessionTicket string) (string, time.Time, error)
	// RefreshTicket re-issues the session ticket with a fresh snapshot timestamp when
	// the resources upload is retried; nil keeps the session's timestamp
	RefreshTicket TicketRefreshFunc
	// Database jobs assigned to this agent (dump pods): DBPassword fetches the job's
	// server-stored password; the per-engine image templates, pod resources/security
	// context and spool size come from the Helm chart; StateSecretName holds the
	// per-job chain state in the agent namespace
	DBPassword                  func(ctx context.Context, ticket string) (string, error)
	DBWorkerImages              map[string]string
	DBWorkerResourcesJSON       string
	DBWorkerSecurityContextJSON string
	DBWorkerSpoolSize           string
	StateSecretName             string
	// SpoolDir stages the resource dump (default <data dir>/spool)
	SpoolDir string
	// LogTail returns the agent's recent log output, attached to failures
	LogTail func() string
	// ReportProgress posts live phase / per-PVC updates to the server (best-effort)
	ReportProgress ProgressFunc

	// Runs tracks in-flight run ids for the orphan sweep. It lives in a named field:
	// worker.RegisterActivity(struct) validates every exported *method* of the struct,
	// so helpers must not be methods on K8sAgentActivities.
	Runs *RunTracker
	// contains filtered or unexported fields
}

K8sAgentActivities are the activities of fallbck-k8s-agent

func NewK8sAgentActivities added in v0.7.2

func NewK8sAgentActivities() *K8sAgentActivities

NewK8sAgentActivities creates a new K8sAgentActivities instance

func (*K8sAgentActivities) BackupKubernetesResources added in v0.7.2

func (a *K8sAgentActivities) BackupKubernetesResources(ctx context.Context, session *temporal.BackupSessionInfo, plan *spec.Plan, volumes []spec.VolumeResult) (*temporal.BackupExecutionResult, error)

BackupKubernetesResources dumps every selected API resource and uploads it together with the run manifest (which embeds the per-volume outcomes; it runs last).

func (*K8sAgentActivities) BackupKubernetesVolume added in v0.7.2

func (a *K8sAgentActivities) BackupKubernetesVolume(ctx context.Context, session *temporal.BackupSessionInfo, plan spec.VolumePlan) (*spec.VolumeResult, error)

BackupKubernetesVolume snapshots/mounts one PVC and uploads it from a worker pod

func (*K8sAgentActivities) DiscoverKubernetesBackup added in v0.7.2

func (a *K8sAgentActivities) DiscoverKubernetesBackup(ctx context.Context, session *temporal.BackupSessionInfo) (*spec.Plan, error)

DiscoverKubernetesBackup plans the run: which volumes, snapshot or live per volume

func (*K8sAgentActivities) ExecuteKubernetesDatabaseBackup added in v0.9.5

func (a *K8sAgentActivities) ExecuteKubernetesDatabaseBackup(ctx context.Context, session *temporal.BackupSessionInfo) (*temporal.BackupExecutionResult, error)

ExecuteKubernetesDatabaseBackup runs a database job assigned to this kubernetes agent: the database is dumped from a short-lived pod in its namespace (engine image with the client tools, this agent's binary injected) and uploaded to PBS from there.

type KeyFetcher added in v0.13.0

type KeyFetcher = func(ctx context.Context, ticket string) (*backup.Encryption, error)

KeyFetcher retrieves the run's client-side encryption key with its ticket

type ProgressFunc added in v0.9.0

type ProgressFunc func(ctx context.Context, ticket string, runID uuid.UUID, phase string, items map[string]rundetail.ProgressItem) error

ProgressFunc posts live run progress (phase and/or per-item statuses) to the server.

type RunTracker added in v0.7.2

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

RunTracker counts in-flight backup runs (consulted by the orphan sweep)

func (*RunTracker) Active added in v0.7.2

func (t *RunTracker) Active(runID string) bool

Active reports whether a run currently executes on this agent

type ServerActivities

type ServerActivities struct {
	DB           *db.DB
	Config       *config.ServerConfig
	TokenManager *auth.TokenManager
}

ServerActivities provides activities executed on the central FallBCK server

func NewServerActivities

func NewServerActivities(database *db.DB, cfg *config.ServerConfig, tm *auth.TokenManager) *ServerActivities

NewServerActivities creates a new ServerActivities instance

func (*ServerActivities) FinalizeBackupRun

func (s *ServerActivities) FinalizeBackupRun(ctx context.Context, session *temporal.BackupSessionInfo, result *temporal.BackupExecutionResult) error

FinalizeBackupRun updates the backup run record in the database with results and deduplication metrics

func (*ServerActivities) PrepareBackupSession

func (s *ServerActivities) PrepareBackupSession(ctx context.Context, jobID uuid.UUID) (*temporal.BackupSessionInfo, error)

PrepareBackupSession validates job parameters and generates a short-lived backup ticket

type TicketRefreshFunc added in v0.9.5

type TicketRefreshFunc func(ctx context.Context, ticket string) (ticket2 string, backupTime int64, err error)

TicketRefreshFunc re-issues a run's backup ticket with a fresh snapshot timestamp

Jump to

Keyboard shortcuts

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