backup

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Backup and restore of an installation: full backups of every profile or some into one signed archive, quick snapshots of what icebath can't work without, the backups taken on a schedule and before an update, their verification, and their restore into this installation or another, every running icebath of this computer taking the restored files up again. What each feature keeps, and what of it a backup holds, the feature says through a registrant

Index

Constants

View Source
const (
	ByHand     = "hand"
	BySchedule = "schedule"
	ByUpdate   = "update"
	ByRestore  = "restore"
)

Why a backup was taken, which its manifest names and the name of an archive starts with

View Source
const ByPerson = "snapshot"

Why a quick snapshot was taken when a person asked for it

Variables

View Source
var ErrBusy = errors.New("Another backup or restore is going on. Try again once it finishes.")

Refusal of a backup or a restore while another one goes on in this icebath or another

Functions

This section is empty.

Types

type Archive

type Archive struct {
	Path string
	Size int64
	// When the file was written, which is when it was taken
	Modified time.Time
	// What it holds and who signed it, nil with the reason it does not read
	Manifest *Manifest
	Signer   Signer
	Problem  string
}

An archive in the folder of archives as a list shows it

func (Archive) Name

func (a Archive) Name() string

Name of the archive's file

func (Archive) Reason

func (a Archive) Reason() string

Why the archive was taken, by its manifest or by its name

type Ask

type Ask struct {
	// Profiles whose folders it holds, every profile when none
	Profiles []string
	// What every profile shares is left out, for a backup of one profile to bring into another installation
	Alone bool
	// Keys and passwords are left out whatever the settings say
	Bare bool
	// File or folder it is written to, the folder of archives when empty
	Output string
}

What a backup is asked to hold, and where it goes

type Backup

type Backup struct {
	Registry
	// contains filtered or unexported fields
}

The backups of every profile of this installation: the archives, the snapshots, the schedule, the backup before an update and the restores, of what every feature says it keeps

func New

func New(cfg *config.Config, pr *profile.Profiles, rn *runner.Runner) *Backup

func (*Backup) AfterUpdate

func (b *Backup) AfterUpdate(ctx context.Context, say func(line string)) []Damage

Checks every database every feature keeps after an update, restoring one that fails from the newest snapshot holding a good copy while Repair from snapshots is on, each step said as a line a person reads: what it found, none when every database is whole

func (*Backup) Archives

func (b *Backup) Archives() ([]Archive, error)

Every archive in the folder of archives, the newest first, each with its manifest read

func (*Backup) BeforeUpdate

func (b *Backup) BeforeUpdate(ctx context.Context, mode string, say func(line string)) Taken

Takes what the person asked for this update, or what Before an update says when mode is empty: off takes nothing, snapshot the snapshot of every profile, full the snapshot and an archive of everything in the folder of archives, keys and passwords in it as it stays on this computer. A database the snapshot finds damaged is said, with whether the snapshot holds a good copy of it. Each step is said as a line a person reads, say may be nil

func (*Backup) Check

func (b *Backup) Check(ctx context.Context) ([]Damage, error)

Every database every feature keeps that fails SQLite's check or its feature's own, each with the newest snapshot holding a good copy of it, changing nothing

func (*Backup) Contents

func (b *Backup) Contents(ask Ask) ([]Content, []string, error)

What a full backup of the ask would hold now, largest first, and the titles the settings leave out

func (*Backup) Create

func (b *Backup) Create(ctx context.Context, ask Ask, progress Progress) (Made, error)

Takes a full backup into one signed archive, for a person who asked

func (*Backup) Earlier

func (b *Backup) Earlier(id, profile, rel string) ([]byte, error)

One file of a profile as the snapshot of the id holds it, rel slash separated below the profile's folder, such as the .env an undo of an import reads the keys it replaced from; refused when the snapshot holds none of it or holds another than its manifest says

func (*Backup) Find

func (b *Backup) Find(name string) (string, error)

The archive a person names: a path, or the name of one in the folder of archives, or its place in the list from one

func (*Backup) FindSnapshot

func (b *Backup) FindSnapshot(name string) (string, error)

Folder of the snapshot a person names: by its id, or by its place in the list from one, the newest first

func (*Backup) Folder

func (b *Backup) Folder() string

Folder archives are written to and looked for in

func (*Backup) KeyPath

func (b *Backup) KeyPath() string

File of the key this installation signs its backups with, which no backup ever holds

func (*Backup) Last

func (b *Backup) Last() (Last, bool)

What the schedule took last, false when it never took anything

func (*Backup) Look

func (b *Backup) Look(path string) Archive

The archive at the path as a list shows it, read wherever it lies

func (*Backup) Mend

func (b *Backup) Mend(ctx context.Context, say func(line string)) ([]Damage, error)

Checks every database every feature keeps, and restores each that fails from the newest snapshot holding a good copy of it, the profile it is of held from renames and deletes while nothing runs in it: what it found, none when every database is whole

func (*Backup) Next

func (b *Backup) Next() (time.Time, bool)

When the schedule takes its next backup, false while it is off

func (*Backup) Outside

func (b *Backup) Outside() []string

Folders outside icebath's folder where this installation keeps backups, for an uninstall to offer removing or keeping: the folder of archives when the settings point it elsewhere; none while backups stay in icebath's folder, which goes with it

func (*Backup) Prune

func (b *Backup) Prune(ctx context.Context, keep int) ([]string, error)

Removes the oldest archives icebath made past keep of each reason, now: those of the schedule and of updates by their own settings when keep is zero; what it removed

func (*Backup) PruneSnapshots

func (b *Backup) PruneSnapshots(ctx context.Context, keep int) (int, error)

Removes the oldest snapshots past keep, as many as the settings keep for none: how many went

func (*Backup) PublicKey

func (b *Backup) PublicKey() string

Public key of this installation as a manifest names it, empty when there is none yet

func (*Backup) Register

func (b *Backup) Register(registrant Registrant)

Adds a registrant; a registry nested in the host reaches it through Host

func (*Backup) Remove

func (b *Backup) Remove(ctx context.Context, path string) error

Removes the archive at the path, one of the folder of archives or any the person names

func (*Backup) RemoveSnapshot

func (b *Backup) RemoveSnapshot(ctx context.Context, dir string) error

Removes the snapshot of the folder

func (*Backup) Restore

func (b *Backup) Restore(ctx context.Context, path string, r Restoring, progress Progress) (Outcome, error)

Writes the backup at the path, an archive or the folder of a snapshot, back into this installation: its every member checked against its digest before anything changes, a snapshot taken of what it writes over, the profiles held from every rename and delete while nothing runs in them, and every icebath of this computer told to take the files up again

func (*Backup) Snapshot

func (b *Backup) Snapshot(ctx context.Context, label string) (string, error)

Takes a quick snapshot of what every profile and what they share can't work without, under the label a person gave it: its id, empty when there was nothing to take

func (*Backup) SnapshotFolder

func (b *Backup) SnapshotFolder() string

Folder of the quick snapshots

func (*Backup) Snapshots

func (b *Backup) Snapshots() ([]Snapshot, error)

Every quick snapshot, the newest first, each with its manifest read; one whose manifest does not read is listed with why

func (*Backup) Tend

func (b *Backup) Tend(ctx context.Context) error

The work of backups while icebath runs, which the service of backups does until the context ends: every few seconds the restores another icebath made are taken up, and a backup the schedule owes is taken

func (*Backup) Verify

func (b *Backup) Verify(ctx context.Context, path string, progress Progress) (Verdict, error)

Verifies the backup at the path, an archive or the folder of a snapshot: who signed it, every member against its digest, and every database against SQLite's check and its feature's own

type Checker

type Checker interface {
	// Why the database at the path, which is what at names (its path below its part as Keeps names it, whether it is shared, its title)
	// or a copy of it, can't be used for the profile of the settings; empty when it can, and for what the feature does not keep
	Check(ctx context.Context, cfg *config.Config, at Kept, path string) string
}

Registrant that checks its databases beyond what SQLite finds of them, such as the tables a store needs

type Content

type Content struct {
	// What the features call it, or the part of the installation it is in
	Title string
	Kind  Kind
	Files int
	Bytes int64
}

What a full backup holds of one thing the features keep

type Counter

type Counter interface {
	// How many records the database at the path holds, which is what at names, and what they are in the plural; false for what the
	// feature does not keep, or a database that can't be counted
	Count(ctx context.Context, at Kept, path string) (int64, string, bool)
}

Registrant whose databases hold records a person counts, so a restore that leaves fewer says so

type Damage

type Damage struct {
	// Profile it is of, empty for one every profile shares; what a person calls it; where it is
	Profile, Title, Path string
	Problem              string
	// Newest snapshot holding a good copy of it, which a repair restores; empty when none does
	Copy string
	// Snapshot a good copy was restored from, empty when none was; why it could not be restored
	Restored, Failure string
}

A database a feature keeps that failed its check, and what came of mending it

type Entry

type Entry struct {
	Name     string    `json:"name"`
	Size     int64     `json:"size"`
	Mode     uint32    `json:"mode"`
	Modified time.Time `json:"modified"`
	// SHA-256 of what it holds, hex
	Digest   string `json:"sha256"`
	Kind     string `json:"kind"`
	Database bool   `json:"database,omitempty"`
	Title    string `json:"title,omitempty"`
	// It holds credentials among what is no credential, taken out of it when the backup holds no keys
	Mixed bool `json:"mixed,omitempty"`
	// Text of a link, empty for a file
	Link string `json:"link,omitempty"`
}

One file a backup holds

type Kept

type Kept struct {
	// Slash separated, below the profile's folder, or below the folder every profile shares when Shared; a whole path for a place outside
	// icebath's folder, kept under the user's home or where it is. A part of * stands for any one name
	Path   string
	Shared bool
	Kind   Kind
	// A SQLite database, or a folder of them: copied through SQLite while it is in use, checked before it is restored, restored into the
	// file in use so its holders keep it
	Database bool
	// What a person calls it, such as Sessions or File checkpoints: entries of kind Data with a title can be left out of archives in the
	// settings, and what a backup lists is said by these titles; empty for what is listed with the feature's other files
	Title string
	// It holds credentials among what is no credential, such as keys among the settings: an archive without keys and passwords holds it
	// as the feature's Scrubber gives it
	Mixed bool
}

A file or folder a feature keeps. A folder holds everything below it; a more specific entry below it decides for what it names

type Kind

type Kind int

What a backup does with what a feature keeps

const (
	// Full backups only: what the feature made or the person put there, such as skills or logs, and what no entry names
	Data Kind = iota
	// Every backup, the quick snapshots and the one before an update among them: what the feature can't work without
	State
	// Credentials, such as a key or the session of a chat app: every backup that stays on this computer, a full backup only while Keys and
	// passwords is on; restored for the owner alone
	Secret
	// No backup, and a restore never writes over it: caches, programs fetched again, locks, sockets, what only this computer's processes
	// read, and keys no one should carry off by accident, such as one kept beside the store it opens
	Never
)

func (Kind) String

func (k Kind) String() string

Word a manifest names the kind by

type Last

type Last struct {
	At time.Time `json:"at"`
	// What it took, snapshot or full, and the id of the snapshot or the path of the archive
	What  string `json:"what"`
	Taken string `json:"taken,omitempty"`
	// Why it took nothing, empty when it did
	Failure string `json:"failure,omitempty"`
}

What the schedule took last, which every icebath of this computer reads before it takes another

type Made

type Made struct {
	Path     string
	Manifest *Manifest
	// Bytes of the archive
	Size int64
	// Archives removed past the number kept
	Pruned []string
}

An archive written

func (Made) Incomplete

func (m Made) Incomplete() bool

Holds less than was asked: files that could not be taken, which the manifest lists with why

type Manifest

type Manifest struct {
	Format int `json:"format"`
	// Name of the archive without its ending, or id of the snapshot
	ID   string    `json:"id"`
	Made time.Time `json:"made"`
	// Why it was taken: hand, schedule, update, restore or snapshot
	Reason string `json:"reason"`
	Label  string `json:"label,omitempty"`
	// Version of the icebath that took it, the computer, and where icebath's folder and the user's home were
	Version string `json:"version"`
	Host    string `json:"host"`
	Root    string `json:"root"`
	Home    string `json:"home"`
	// Profiles whose folders it holds, whether what every profile shares, and whether keys and passwords
	Profiles []string `json:"profiles"`
	Shared   bool     `json:"shared"`
	Secrets  bool     `json:"secrets"`
	// Titles the settings left out, files over the size limit of a snapshot, and files that could not be taken with why
	Left    []string `json:"left,omitempty"`
	Skipped []string `json:"skipped,omitempty"`
	Failed  []string `json:"failed,omitempty"`
	// A database was over the size limit of a snapshot, so the snapshots before it are not pruned
	Oversized bool    `json:"oversized,omitempty"`
	Members   []Entry `json:"members"`
	// Public key of the installation that signed it
	Key string `json:"key"`
}

What a backup is, which the archive or the snapshot carries beside what it holds

func (*Manifest) Bytes

func (m *Manifest) Bytes() int64

Bytes of the files the manifest lists

func (*Manifest) Holds

func (m *Manifest) Holds(part string) bool

Whether the part of the name is in the backup

type Outcome

type Outcome struct {
	Manifest *Manifest
	Signer   Signer
	// What it wrote over
	Scope Scope
	// Files written back
	Written int
	// Files of the backup this computer keeps its own of, such as a lock or what no backup holds, and those that could not be written, each
	// with why
	Kept   []string
	Failed []string
	// Snapshot of what it wrote over, taken first, which restores it as it was
	Undo string
	// Stores that hold fewer records than before, each a sentence
	Fewer []string
	// Windows working on the profiles, which stopped it with nothing done until the one asking says to go ahead
	Windows int
}

What a restore did

type Progress

type Progress func(line string, done, total int)

What a backup or a restore tells as it goes: a line a person reads, empty while it only moves on, and how far it got of the files, both negative for a line that leaves the count as it was

type Registrant

type Registrant interface {
	// What the feature keeps for the profile of the settings, what it keeps once for every profile marked Shared. Read quickly, no I/O
	Keeps(cfg *config.Config) []Kept
}

type Registry

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

func (*Registry) Host

func (r *Registry) Host() *Backup

Host the registry is nested in, through which plugins reach the backups

func (*Registry) Keeps

func (r *Registry) Keeps(cfg *config.Config) []Kept

func (*Registry) Register

func (r *Registry) Register(registrant Registrant)

type Restorer

type Restorer interface {
	// Lets go of what the scope names before a restore in this icebath writes over it: closes its databases, stops writing its files
	Release(scope Scope) error
	// Takes up again what the scope names once a restore wrote over it, in this icebath or in another one of this computer: opens its
	// databases anew, drops what it read of its files before
	Restored(scope Scope) error
}

Registrant that holds what it keeps open or in memory

type Restoring

type Restoring struct {
	// Profiles of the backup whose folders it writes back, every one it holds when none
	Profiles []string
	// What every profile shares, and what lay outside icebath's folder, is left as it is
	Alone bool
	// Only what every profile shares, and what lay outside icebath's folder, is written back, no profile's folder
	Common bool
	// The one profile asked for is written back under this name, as a new profile or over the one of that name
	As string
	// The person confirmed restoring a backup another installation signed, or none signed
	Trust bool
	// The windows working on the profiles may go on while their files are written over
	Others bool
	// Window that asks, which never counts among the windows on the profiles
	Window string
}

What a restore is asked to write back

type Scope

type Scope struct {
	Profiles []string
	Shared   bool
}

What a restore wrote over: the profiles whose folders it restored, and whether what every profile shares

func (Scope) Has

func (s Scope) Has(profile string) bool

Whether the scope names the profile

type Scrubber

type Scrubber interface {
	// What the file, which is what at names, holds once the credentials in it are taken out, for an archive that holds none; the data as
	// it is for what the feature does not keep
	Scrub(cfg *config.Config, at Kept, data []byte) []byte
	// What the file of an archive without keys becomes once the credentials of the one in use, live, are put back where it holds none, so
	// a restore of it keeps the keys this computer has; the data as it is for what the feature does not keep
	Rekey(cfg *config.Config, at Kept, data, live []byte) []byte
}

Registrant that keeps credentials inside files beside what is no credential, which it named Mixed

type Signer

type Signer int

Who signed a backup, as its signature and its key stand

const (
	// No signature
	Unsigned Signer = iota
	// A signature that does not hold for the manifest, which changed after it was signed
	Forged
	// Signed by a key neither this installation's nor a trusted one
	Stranger
	// Signed by a key the settings trust
	Trusted
	// Signed by this installation
	Own
)

func (Signer) String

func (s Signer) String() string

Words of who signed a backup, as a person reads them

type Snapshot

type Snapshot struct {
	ID  string
	Dir string
	// What it holds and who signed it, nil with the reason it does not read
	Manifest *Manifest
	Signer   Signer
	Problem  string
}

A quick snapshot as a list shows it

func (Snapshot) Label

func (s Snapshot) Label() string

Label as the snapshot's manifest names it

type Taken

type Taken struct {
	Snapshot string
	Archive  string
	Problems []string
}

What was kept before an update: the id of the snapshot of every profile, the archive when a full backup was taken, and what went wrong, each a sentence. Never a failure: an update goes on whatever it says

type UntrustedError

type UntrustedError struct {
	Signer Signer
	Key    string
}

Refusal of a backup signed by another installation or by none, until the person says to restore it all the same

func (*UntrustedError) Error

func (e *UntrustedError) Error() string

type Verdict

type Verdict struct {
	Manifest *Manifest
	Signer   Signer
	// What is wrong with it, each a sentence: members whose bytes are not those the manifest names, members missing or not listed, and
	// databases that fail their check
	Problems []string
}

What a verification of a backup found

func (Verdict) Whole

func (v Verdict) Whole() bool

Whether the backup holds what its manifest says, signed by a key whose signature holds

Directories

Path Synopsis
Screens of the backups: Backups, the page of their settings area, with the archives, taking one, verifying, restoring and bringing one in from a file, and the check of every database; Snapshots, with the quick snapshots, taking, restoring and removing them
Screens of the backups: Backups, the page of their settings area, with the archives, taking one, verifying, restoring and bringing one in from a file, and the check of every database; Snapshots, with the quick snapshots, taking, restoring and removing them

Jump to

Keyboard shortcuts

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