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
- Variables
- type Archive
- type Ask
- type Backup
- func (b *Backup) AfterUpdate(ctx context.Context, say func(line string)) []Damage
- func (b *Backup) Archives() ([]Archive, error)
- func (b *Backup) BeforeUpdate(ctx context.Context, mode string, say func(line string)) Taken
- func (b *Backup) Check(ctx context.Context) ([]Damage, error)
- func (b *Backup) Contents(ask Ask) ([]Content, []string, error)
- func (b *Backup) Create(ctx context.Context, ask Ask, progress Progress) (Made, error)
- func (b *Backup) Earlier(id, profile, rel string) ([]byte, error)
- func (b *Backup) Find(name string) (string, error)
- func (b *Backup) FindSnapshot(name string) (string, error)
- func (b *Backup) Folder() string
- func (b *Backup) KeyPath() string
- func (b *Backup) Last() (Last, bool)
- func (b *Backup) Look(path string) Archive
- func (b *Backup) Mend(ctx context.Context, say func(line string)) ([]Damage, error)
- func (b *Backup) Next() (time.Time, bool)
- func (b *Backup) Outside() []string
- func (b *Backup) Prune(ctx context.Context, keep int) ([]string, error)
- func (b *Backup) PruneSnapshots(ctx context.Context, keep int) (int, error)
- func (b *Backup) PublicKey() string
- func (b *Backup) Register(registrant Registrant)
- func (b *Backup) Remove(ctx context.Context, path string) error
- func (b *Backup) RemoveSnapshot(ctx context.Context, dir string) error
- func (b *Backup) Restore(ctx context.Context, path string, r Restoring, progress Progress) (Outcome, error)
- func (b *Backup) Snapshot(ctx context.Context, label string) (string, error)
- func (b *Backup) SnapshotFolder() string
- func (b *Backup) Snapshots() ([]Snapshot, error)
- func (b *Backup) Tend(ctx context.Context) error
- func (b *Backup) Verify(ctx context.Context, path string, progress Progress) (Verdict, error)
- type Checker
- type Content
- type Counter
- type Damage
- type Entry
- type Kept
- type Kind
- type Last
- type Made
- type Manifest
- type Outcome
- type Progress
- type Registrant
- type Registry
- type Restorer
- type Restoring
- type Scope
- type Scrubber
- type Signer
- type Snapshot
- type Taken
- type UntrustedError
- type Verdict
Constants ¶
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
const ByPerson = "snapshot"
Why a quick snapshot was taken when a person asked for it
Variables ¶
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
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 (*Backup) AfterUpdate ¶
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 ¶
Every archive in the folder of archives, the newest first, each with its manifest read
func (*Backup) BeforeUpdate ¶
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 ¶
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 ¶
What a full backup of the ask would hold now, largest first, and the titles the settings leave out
func (*Backup) Earlier ¶
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 ¶
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 ¶
Folder of the snapshot a person names: by its id, or by its place in the list from one, the newest first
func (*Backup) KeyPath ¶
File of the key this installation signs its backups with, which no backup ever holds
func (*Backup) Mend ¶
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) Outside ¶
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 ¶
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 ¶
Removes the oldest snapshots past keep, as many as the settings keep for none: how many went
func (*Backup) PublicKey ¶
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 ¶
Removes the archive at the path, one of the folder of archives or any the person names
func (*Backup) RemoveSnapshot ¶
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 ¶
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 ¶
Folder of the quick snapshots
func (*Backup) Snapshots ¶
Every quick snapshot, the newest first, each with its manifest read; one whose manifest does not read is listed with why
func (*Backup) Tend ¶
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
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
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 )
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 ¶
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"`
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
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 ¶
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 Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
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
}
What a restore wrote over: the profiles whose folders it restored, and whether what every profile shares
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 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
type Taken ¶
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 ¶
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
Source Files
¶
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 |