backup

package
v0.1.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package backup implements full-platform disaster recovery (spec §3.11, T-66): a leader backs up the raft state, the cluster CA material and the sealed data key to the same S3 object store the volume snapshots use; `zatterad restore` rebuilds a fresh single-node cluster from the latest backup.

Layout under the store prefix:

backups/<ts>/state.pb.enc  encrypted (data key) marshaled state Snapshot
backups/<ts>/ca.pb.enc     encrypted (data key) CA cert + key PEM
backups/<ts>/keys.pb       ClusterKeyMaterial (data key sealed by passphrase)
backups/<ts>/index.json    plaintext index (pointers + volume snapshot refs)
backups/latest             plaintext "<ts>" pointer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	Version       int         `json:"version"`
	Kind          string      `json:"kind"`
	TimestampUnix int64       `json:"timestamp_unix"`
	KeyVersion    uint32      `json:"key_version"`
	NodeIDs       []string    `json:"node_ids"`
	Volumes       []VolumeRef `json:"volumes"`
}

Index is the plaintext manifest of one full backup. It holds no secrets — only object pointers and the volume snapshots to restore.

func Backup

func Backup(ctx context.Context, in Input) (*Index, error)

Backup writes a full backup and returns its index. It never mutates cluster state (the caller records a BackupRecord).

func Restore

func Restore(ctx context.Context, in RestoreInput) (*Index, error)

Restore rebuilds a fresh single-node cluster from the latest backup: it unseals the data key with the passphrase, decrypts the state + CA, marks the old nodes DOWN (mesh IPs preserved), and bootstraps a raft store in DataDir so a subsequent `zatterad server` comes up with the restored state. It returns the backup index (whose volume refs the operator restores as workers rejoin).

func Verify

func Verify(ctx context.Context, store volumes.ObjectStore, passphrase string) (*Index, *state.Store, error)

Verify downloads and decrypts the latest state backup and returns the object counts — the weekly restore-test uses it to prove a backup is recoverable.

type Input

type Input struct {
	Store       *state.Store
	ObjectStore volumes.ObjectStore
	Sealer      secrets.Sealer // built from the cluster data key (state/CA crypto)
	// KeyMaterial is the cluster's data key already sealed under the recovery
	// passphrase (from state) — stored verbatim so restore unseals with that same
	// passphrase. No fresh passphrase is needed at backup time.
	KeyMaterial *zatterav1.ClusterKeyMaterial
	CACertPEM   []byte
	CAKeyPEM    []byte
	Now         time.Time
}

Input configures a backup run.

type RestoreInput

type RestoreInput struct {
	ObjectStore volumes.ObjectStore
	Passphrase  string
	DataDir     string // fresh, empty
	NodeID      string // the new single-node cluster's id
}

RestoreInput configures a restore into a fresh data dir.

type VolumeRef

type VolumeRef struct {
	VolumeID      string `json:"volume_id"`
	EnvironmentID string `json:"environment_id"`
	Name          string `json:"name"`
	NodeID        string `json:"node_id"`
	ManifestKey   string `json:"manifest_key"` // "" when the volume has no snapshot
}

VolumeRef points at the latest snapshot to restore for a volume.

Jump to

Keyboard shortcuts

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