backup

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package backup implements online backup and restore for BubbleFish Nexus.

Backup creates a crash-safe snapshot of config files, compiled policies, WAL segments, and optionally the SQLite database. Restore verifies SHA256 checksums from a manifest before writing any files.

Reference: Tech Spec Section 14.5.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(opts CreateOptions) error

Create performs an online backup of BubbleFish Nexus state.

Order of operations (per Tech Spec Section 14.5):

  1. Config TOML files (daemon.toml, sources/, destinations/, policies/)
  2. Compiled JSON files (and .sig sidecars)
  3. SQLite database (if --include-db, via VACUUM INTO)
  4. WAL segments (copied LAST for online safety)
  5. manifest.json with SHA256 checksums

func Restore

func Restore(opts RestoreOptions) error

Restore reads a backup and restores all files to their original locations. SHA256 checksums are verified before any files are written.

Without --force, restore refuses to overwrite existing files.

Reference: Tech Spec Section 14.5.

Types

type CreateOptions

type CreateOptions struct {
	Dest      string // destination directory for the backup
	IncludeDB bool   // include SQLite database snapshot
	Logger    *slog.Logger
}

CreateOptions configures a backup create operation.

type Manifest

type Manifest struct {
	Version    string         `json:"version"`
	CreatedAt  time.Time      `json:"created_at"`
	ConfigDir  string         `json:"config_dir"`
	IncludesDB bool           `json:"includes_db"`
	Files      []ManifestFile `json:"files"`
}

Manifest describes a backup's contents. It is written as manifest.json in the backup directory.

type ManifestFile

type ManifestFile struct {
	RelPath  string `json:"rel_path"`
	SHA256   string `json:"sha256"`
	Size     int64  `json:"size"`
	Category string `json:"category"` // "config", "compiled", "wal", "database"
}

ManifestFile is a single file entry within a backup manifest.

type RestoreOptions

type RestoreOptions struct {
	From   string // backup directory to restore from
	Force  bool   // overwrite existing files
	Logger *slog.Logger
}

RestoreOptions configures a backup restore operation.

Jump to

Keyboard shortcuts

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