backup

package
v0.0.0-...-704f996 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalManifest

func MarshalManifest(m *Manifest) ([]byte, error)

MarshalManifest serializes a manifest to JSON.

Types

type BackupOptions

type BackupOptions struct {
	IncludeMetadata bool // back up the SQLite database
	IncludeConfig   bool // back up arc.toml
}

BackupOptions controls what gets backed up and where.

type BackupResult

type BackupResult struct {
	Manifest *Manifest
	Duration time.Duration
}

BackupResult is returned when a backup completes.

type BackupSummary

type BackupSummary struct {
	BackupID      string    `json:"backup_id"`
	CreatedAt     time.Time `json:"created_at"`
	BackupType    string    `json:"backup_type"`
	TotalFiles    int64     `json:"total_files"`
	TotalBytes    int64     `json:"total_size_bytes"`
	DatabaseCount int       `json:"database_count"`
}

BackupSummary is a compact representation of a backup for listing.

func SummaryFromManifest

func SummaryFromManifest(m *Manifest) BackupSummary

SummaryFromManifest creates a compact summary from a full manifest.

type DatabaseInfo

type DatabaseInfo struct {
	Name         string            `json:"name"`
	Measurements []MeasurementInfo `json:"measurements"`
	FileCount    int               `json:"file_count"`
	SizeBytes    int64             `json:"size_bytes"`
}

DatabaseInfo describes a single database within a backup.

type Manager

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

Manager orchestrates backup and restore operations.

func NewManager

func NewManager(cfg *ManagerConfig) (*Manager, error)

NewManager creates a new backup manager.

func (*Manager) CreateBackup

func (m *Manager) CreateBackup(ctx context.Context, opts BackupOptions) (*BackupResult, error)

CreateBackup performs a full backup. It runs synchronously; the API layer launches it in a goroutine and exposes progress via GetProgress().

func (*Manager) DeleteBackup

func (m *Manager) DeleteBackup(ctx context.Context, backupID string) error

DeleteBackup removes all files for a backup from the default backup storage.

func (*Manager) GetBackup

func (m *Manager) GetBackup(ctx context.Context, backupID string) (*Manifest, error)

GetBackup reads and returns the manifest for a specific backup.

func (*Manager) GetProgress

func (m *Manager) GetProgress() *Progress

GetProgress returns the current active operation progress, or nil if idle.

func (*Manager) ListBackups

func (m *Manager) ListBackups(ctx context.Context) ([]BackupSummary, error)

ListBackups returns summaries of all available backups in the default backup storage.

func (*Manager) RestoreBackup

func (m *Manager) RestoreBackup(ctx context.Context, opts RestoreOptions) (*RestoreResult, error)

RestoreBackup restores data from a backup. It runs synchronously; the API layer launches it in a goroutine and exposes progress via GetProgress().

type ManagerConfig

type ManagerConfig struct {
	DataStorage  storage.Backend
	BackupPath   string // local directory for backups
	SQLiteDBPath string
	ConfigPath   string
	Logger       zerolog.Logger
}

ManagerConfig holds configuration for creating a backup manager.

type Manifest

type Manifest struct {
	Version        string         `json:"version"`
	BackupID       string         `json:"backup_id"`
	CreatedAt      time.Time      `json:"created_at"`
	BackupType     string         `json:"backup_type"` // "full" (future: "incremental")
	Databases      []DatabaseInfo `json:"databases"`
	TotalFiles     int64          `json:"total_files"`
	TotalSizeBytes int64          `json:"total_size_bytes"`
	HasMetadata    bool           `json:"has_metadata"`
	HasConfig      bool           `json:"has_config"`
}

Manifest describes the contents of a backup.

func UnmarshalManifest

func UnmarshalManifest(data []byte) (*Manifest, error)

UnmarshalManifest deserializes a manifest from JSON.

type MeasurementInfo

type MeasurementInfo struct {
	Name      string `json:"name"`
	FileCount int    `json:"file_count"`
	SizeBytes int64  `json:"size_bytes"`
}

MeasurementInfo describes a single measurement within a database backup.

type Progress

type Progress struct {
	Operation      string     `json:"operation"` // "backup" or "restore"
	BackupID       string     `json:"backup_id"`
	Status         string     `json:"status"` // "running", "completed", "failed"
	TotalFiles     int64      `json:"total_files"`
	ProcessedFiles int64      `json:"processed_files"`
	TotalBytes     int64      `json:"total_bytes"`
	ProcessedBytes int64      `json:"processed_bytes"`
	StartedAt      time.Time  `json:"started_at"`
	CompletedAt    *time.Time `json:"completed_at,omitempty"`
	Error          string     `json:"error,omitempty"`
}

Progress tracks the state of a running backup or restore operation.

type RestoreOptions

type RestoreOptions struct {
	BackupID        string
	RestoreData     bool // restore parquet files
	RestoreMetadata bool // restore SQLite database
	RestoreConfig   bool // restore arc.toml (requires restart)
}

RestoreOptions controls what gets restored and from where.

type RestoreResult

type RestoreResult struct {
	Manifest *Manifest
	Duration time.Duration
}

RestoreResult is returned when a restore completes.

Jump to

Keyboard shortcuts

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