mirror of
https://github.com/TronoSfera/backupy-agent.git
synced 2026-05-18 18:13:30 +03:00
Source ports from the TronoSfera/backupy-cloud monorepo:
- apps/agent/ — Go agent (WSS client, persistent queue, Docker
discovery, 5 DB drivers: PG/MySQL/Mongo/Redis/SQLite,
pre/post hooks, Prometheus metrics)
- apps/backupy-decrypt/ — standalone CLI for client-side decryption
- packages/proto/ — protobuf wire format (generated .pb.go committed
so the repo builds without protoc)
- docs/ — agent spec + wire-protocol contract
Apache-2.0 license. Image published to ghcr.io/tronosfera/backupy-agent
on every v* tag via .github/workflows/release.yml (multi-arch amd64+arm64).
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
// Package pipeline executes the agent's backup pipeline end-to-end.
|
|
//
|
|
// Stages (see docs/03-agent-spec.md → "Backup pipeline"):
|
|
//
|
|
// 1. Driver.Validate — smoke-test connectivity, fail fast.
|
|
// 2. Driver.Dump — produce plaintext bytes.
|
|
// 3. zstd compression — streaming.
|
|
// 4. AES-256-GCM encryption — streaming, framed chunks.
|
|
// 5. SHA-256 over the ciphertext (the blob actually uploaded to S3).
|
|
// 6. HTTP PUT via presigned URL.
|
|
// 7. Build BackupCompleted with all metadata.
|
|
//
|
|
// All interfaces live in this file. Concrete drivers (pg_dump, mysqldump)
|
|
// and the streaming primitives (compress, encrypt, upload, runner) live
|
|
// in sibling files.
|
|
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
backupv1 "github.com/backupy/backupy/packages/proto/gen/go/backupv1"
|
|
)
|
|
|
|
// Driver produces a database dump as a stream of bytes and reports the
|
|
// engine version string surfaced in BackupCompleted.db_engine_version.
|
|
type Driver interface {
|
|
// Name identifies the driver in logs and metrics ("pg_dump", "mysqldump").
|
|
Name() string
|
|
|
|
// Validate performs a fast smoke test: can we even reach the
|
|
// database with the supplied credentials? Implementations should
|
|
// NOT execute a full dump here — a `SELECT 1` (or equivalent) is
|
|
// enough. Returns nil on success.
|
|
Validate(ctx context.Context, target *backupv1.Target) error
|
|
|
|
// Dump streams a logical-or-physical backup to out. It MUST honour
|
|
// ctx cancellation promptly so CancelJob is responsive.
|
|
Dump(ctx context.Context, target *backupv1.Target, out io.Writer) (DumpInfo, error)
|
|
}
|
|
|
|
// DumpInfo carries metadata produced during the dump stage.
|
|
type DumpInfo struct {
|
|
// EngineVersion is the human-readable backend version string, e.g.
|
|
// "PostgreSQL 16.2" or "MySQL 8.0.36". Used verbatim for the
|
|
// BackupCompleted.db_engine_version field.
|
|
EngineVersion string
|
|
}
|