backup

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package backup owns the portable, verified suga data backup archive format.

Index

Constants

View Source
const FormatVersion = 1

Variables

This section is empty.

Functions

func Restore

func Restore(ctx context.Context, archivePath, home string, noAuto bool, autoBackup func(string) error) (string, error)

func ToolBodyCheck

func ToolBodyCheck(ctx context.Context, home string) (store.ToolBodyCheckReport, error)

ToolBodyCheck verifies the installed session files against the installed ledger, the same check as `suga data bodies --check`, so a restore that did not bring a tool body file back is reported right away.

Types

type File

type File struct {
	Path string `json:"path"`
	// Category marks the files that are not ordinary data trees; tool body files
	// carry categoryToolBodies so the spill accounting can leave them out.
	Category string `json:"category,omitempty"`
	Size     int64  `json:"size"`
	SHA256   string `json:"sha256"`
	Source   string `json:"-"`
}

type Manifest

type Manifest struct {
	FormatVersion int       `json:"format_version"`
	CreatedAt     time.Time `json:"created_at"`
	SugaVersion   string    `json:"suga_version"`
	Files         []File    `json:"files"`
	Spill         SpillInfo `json:"spill"`
	// ToolBodies counts the session files that hold moved tool result bodies.
	// They are always included, unlike spill: a stub in the ledger only names an
	// offset in its file, so the file is the only copy of the body.
	ToolBodies ToolBodiesInfo `json:"tool_bodies"`
	// Images counts the session image files the backup always carries
	// (sessions/<id>/images/, design 0.3).
	Images SessionImagesInfo `json:"session_images"`
}

func Create

func Create(ctx context.Context, opts Options) (Manifest, error)

func Validate

func Validate(path, home string) (Manifest, error)

Validate checks the archive central directory, manifest and every file hash without changing the home directory.

type Options

type Options struct {
	Home         string
	Output       string
	IncludeSpill bool
	SugaVersion  string
}

type SessionImagesInfo

type SessionImagesInfo struct {
	FileCount int   `json:"file_count"`
	Bytes     int64 `json:"bytes"`
}

SessionImagesInfo counts the session image files a backup carries.

type SpillInfo

type SpillInfo struct {
	Policy        string `json:"policy"`
	FileCount     int    `json:"file_count"`
	Bytes         int64  `json:"bytes"`
	OmittedBytes  int64  `json:"omitted_bytes"`
	OmittedReason string `json:"omitted_reason,omitempty"`
}

type ToolBodiesInfo

type ToolBodiesInfo struct {
	FileCount int   `json:"file_count"`
	Bytes     int64 `json:"bytes"`
}

Jump to

Keyboard shortcuts

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