backup

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ManifestVersionV1 identifies the first stable backup manifest schema.
	ManifestVersionV1 = "backup-manifest-v1"

	// DBModeEmbedded indicates the database runs in embedded mode.
	DBModeEmbedded = "embedded"
	// DBDriverSQLite indicates SQLite as the database engine.
	DBDriverSQLite = "sqlite"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactDescriptor

type ArtifactDescriptor struct {
	ChecksumSHA256 string `json:"checksum_sha256"`
	SizeBytes      int64  `json:"size_bytes"`
}

ArtifactDescriptor describes the exported backup artifact.

type CreateRequest

type CreateRequest struct {
	SQLitePath    string
	SchemaVersion string
	Storage       StorageLocation
	CreatedAt     time.Time
}

CreateRequest defines input for generating a backup manifest.

type DatabaseDescriptor

type DatabaseDescriptor struct {
	Mode          string `json:"mode"`
	Driver        string `json:"driver"`
	SchemaVersion string `json:"schema_version"`
	SourcePath    string `json:"source_path"`
}

DatabaseDescriptor describes the source DB for a backup.

type Driver

type Driver interface {
	Create(ctx context.Context, req CreateRequest) (Manifest, error)
}

Driver creates backup manifests from runtime data.

type Manifest

type Manifest struct {
	Version   string             `json:"version"`
	CreatedAt time.Time          `json:"created_at"`
	Database  DatabaseDescriptor `json:"database"`
	Artifact  ArtifactDescriptor `json:"artifact"`
	Storage   StorageLocation    `json:"storage"`
}

Manifest is the typed backup descriptor produced by backup drivers.

func (Manifest) Validate

func (m Manifest) Validate() error

Validate validates manifest correctness.

type NoopRestorer

type NoopRestorer struct{}

NoopRestorer validates restore manifests without mutating runtime state.

func (NoopRestorer) Restore

Restore validates the provided manifest.

type Provider

type Provider string

Provider identifies where backup artifacts are stored.

const (
	ProviderLocal        Provider = "local"
	ProviderS3Compatible Provider = "s3-compatible"
)
type RecordLinks struct {
	IncidentID string `json:"incident_id,omitempty"`
	RecoveryID string `json:"recovery_id,omitempty"`
	DeployID   string `json:"deploy_id,omitempty"`
}

RecordLinks carries stable external identifiers without introducing storage dependencies.

func (RecordLinks) Empty

func (l RecordLinks) Empty() bool

func (RecordLinks) Normalized

func (l RecordLinks) Normalized() RecordLinks

type RestoreEvidence

type RestoreEvidence struct {
	Status                  string             `json:"status"`
	AcceptedManifestVersion string             `json:"accepted_manifest_version"`
	ArtifactChecksumSHA256  string             `json:"artifact_checksum_sha256"`
	Database                DatabaseDescriptor `json:"database"`
	RecordLinks             RecordLinks        `json:"record_links,omitempty"`
	PostRestoreChecks       []string           `json:"post_restore_checks"`
}

RestoreEvidence is the machine-readable post-restore contract returned to callers.

func BuildRestoreEvidence

func BuildRestoreEvidence(manifest Manifest, links RecordLinks) RestoreEvidence

BuildRestoreEvidence returns a machine-readable restore evidence payload.

type RestoreRequest

type RestoreRequest struct {
	Manifest Manifest
}

RestoreRequest defines input for restore operations.

type Restorer

type Restorer interface {
	Restore(ctx context.Context, req RestoreRequest) error
}

Restorer validates and applies restore operations.

type RuntimeContract

type RuntimeContract struct {
	ManifestVersion string                 `json:"manifest_version"`
	RestoreEvidence RuntimeRestoreEvidence `json:"restore_evidence"`
}

func RuntimeContractMetadata

func RuntimeContractMetadata() RuntimeContract

type RuntimeRestoreEvidence

type RuntimeRestoreEvidence struct {
	Status                  string   `json:"status"`
	AcceptedManifestVersion string   `json:"accepted_manifest_version"`
	PostRestoreChecks       []string `json:"post_restore_checks"`
	RecordLinks             []string `json:"record_links"`
}

type S3ProviderConfig

type S3ProviderConfig struct {
	Endpoint  string
	Region    string
	Bucket    string
	Prefix    string
	AccessKey string
	SecretKey string
	UseSSL    bool
}

S3ProviderConfig describes the S3-compatible provider boundary.

func (S3ProviderConfig) StorageLocation

func (c S3ProviderConfig) StorageLocation(objectKey string) (StorageLocation, error)

StorageLocation builds a storage location for an object key.

func (S3ProviderConfig) Validate

func (c S3ProviderConfig) Validate() error

Validate validates S3-compatible provider configuration.

type SQLiteDriver

type SQLiteDriver struct {
	Now func() time.Time
}

SQLiteDriver creates SQLite backup manifests from on-disk DB files.

func NewSQLiteDriver

func NewSQLiteDriver() SQLiteDriver

NewSQLiteDriver returns a SQLite driver using the current clock.

func (SQLiteDriver) Create

Create builds a typed manifest for a SQLite backup artifact.

type StorageLocation

type StorageLocation struct {
	Provider Provider `json:"provider"`
	URI      string   `json:"uri,omitempty"`
	Endpoint string   `json:"endpoint,omitempty"`
	Region   string   `json:"region,omitempty"`
	Bucket   string   `json:"bucket,omitempty"`
	Key      string   `json:"key,omitempty"`
}

StorageLocation identifies where the artifact is stored.

func (StorageLocation) Validate

func (l StorageLocation) Validate() error

Validate validates storage target metadata.

Jump to

Keyboard shortcuts

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