backup

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

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

View Source
const (
	ActionBackup  = "system.backup"
	ActionRestore = "system.restore"
)

Audit actions in the instance log.

View Source
const Format = "myownpki-backup/1"

Format names the layout of a backup directory.

View Source
const KindAuthKey store.Kind = "auth_key"

KindAuthKey marks auth.key in the manifest.

View Source
const ManifestFile = "manifest.json"

ManifestFile is written last: a directory without it is not a backup.

View Source
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

View Source
var ErrRefused = errors.New("the backup is refused")

ErrRefused wraps the problems of a backup that may not be restored.

Functions

This section is empty.

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.

func Create

func Create(ctx context.Context, dir string, o Options) (*Manifest, error)

Create writes a backup into dir, which must not exist yet.

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 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.

func Restore

func Restore(ctx context.Context, dir, pin string, o Options) (*Report, error)

Restore checks the backup and moves it into the data directory of o, which must be empty or missing. pin as for Verify.

func Verify

func Verify(ctx context.Context, dir, pin string) (*Report, error)

Verify runs every check of a restore on a copy and writes nothing else. pin is the checkpoint key fingerprint noted at init ("" = all checkpoints must use the key the manifest names).

Jump to

Keyboard shortcuts

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