Documentation
¶
Overview ¶
Package backup makes, checks and restores backups of an instance (PHASE1 step 16): every database as one consistent copy (VACUUM INTO, also while the server runs), the audit databases last, a manifest with SHA-256 per file and the head of every audit chain. A restore goes only into an empty data directory and only after every check passed.
Index ¶
Constants ¶
const ( ActionBackup = "system.backup" ActionRestore = "system.restore" )
Audit actions in the instance log.
const Format = "myownpki-backup/1"
Format names the layout of a backup directory.
const KindAuthKey store.Kind = "auth_key"
KindAuthKey marks auth.key in the manifest.
const ManifestFile = "manifest.json"
ManifestFile is written last: a directory without it is not a backup.
const MaxKeep = 1000
MaxKeep bounds --keep.
const UnverifiedSuffix = "-unverified"
UnverifiedSuffix marks a scheduled backup whose check failed; Prune never deletes it and it doesn't count as one of the kept backups.
const Warning = "This backup holds the CA and certificate keys, encrypted with the root key. " +
"Keep the unseal passphrase and the recovery key apart from it – whoever has both can sign as your CAs."
Warning is shown at every backup (owner decision 2).
Variables ¶
var ErrRefused = errors.New("the backup is refused")
ErrRefused wraps the problems of a backup that may not be restored.
Functions ¶
func ScheduledName ¶ added in v0.2.2
ScheduledName is the directory name of a scheduled backup made at t.
Types ¶
type File ¶
type File struct {
Path string `json:"path"`
Kind store.Kind `json:"kind"` // system, pki, audit; "auth_key"
Tenant string `json:"tenant,omitempty"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
Migration int `json:"migration,omitempty"`
}
File is one file of the backup; Path is relative to the data directory.
type Log ¶
type Log struct {
Scope string `json:"scope"`
Path string `json:"path"`
Head string `json:"head"` // seq:hash
Entries int64 `json:"entries"`
LastCheckpoint *audit.CheckpointInfo `json:"last_checkpoint,omitempty"`
}
Log is the state of one audit log in the backup.
type Manifest ¶
type Manifest struct {
Format string `json:"format"`
CreatedAt string `json:"created_at"`
Version string `json:"version"`
Tenants []string `json:"tenants"`
Files []File `json:"files"`
Audit []Log `json:"audit"`
// CheckpointKey is the fingerprint of the key that signs the audit
// checkpoints – compare it with the one noted at init.
CheckpointKey string `json:"checkpoint_key"`
// AuthKey: auth.key is in the backup (it lived in the data directory).
AuthKey bool `json:"auth_key_included"`
}
Manifest describes a backup.
type Options ¶
type Options struct {
Layout store.Layout
AuthKeyFile string // config auth.key_file
Clock clock.Clock
Who keys.Who
}
Options for Create and Restore.
type PruneResult ¶ added in v0.2.2
type PruneResult struct {
Kept []string // the newest valid scheduled backups, newest first
Deleted []string // oldest first
Skipped []Skipped
}
PruneResult says what Prune did (or, with dryRun, would do).
func Prune ¶ added in v0.2.2
func Prune(parent string, keep int, dryRun bool) (*PruneResult, error)
Prune keeps the newest keep scheduled backups in parent and deletes the older ones. keep must be at least 1, so the newest backup always stays.
func (*PruneResult) String ¶ added in v0.2.2
func (r *PruneResult) String() string
String sums a result up in one line.
type Report ¶
type Report struct {
Manifest *Manifest
// Problems refuse a restore.
Problems []string
// Certificates whose name index was compared.
Certificates int
// Notes are for the operator (auth.key, migrations to apply).
Notes []string
}
Report is the result of checking a backup.
type Skipped ¶ added in v0.2.2
type Skipped struct {
Name, Reason string
}
Skipped is a directory that looks like a scheduled backup but is left alone.
type TimerStatus ¶ added in v0.2.2
type TimerStatus struct {
// Newest is the time of the newest scheduled backup (from its name);
// zero = there is none. A backup that failed its check doesn't count.
Newest time.Time
// Unverified are the backups that failed their check, oldest first.
Unverified []string
}
TimerStatus is what the dashboard shows about the scheduled backups in a directory (v0.2.2, owner 2026-10-24).
func ReadTimerStatus ¶ added in v0.2.2
func ReadTimerStatus(parent string) (TimerStatus, error)
ReadTimerStatus lists parent by name only – it opens no backup, so the dashboard can call it on every view. A missing parent is no error: the timer hasn't run yet (or isn't installed).
func (TimerStatus) Seen ¶ added in v0.2.2
func (s TimerStatus) Seen() bool
Seen reports whether the timer has ever written a backup here.