backup

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 18 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

Package backup writes and restores password-encrypted archives of nerdui's own data: the database, the managed stacks and the Git stacks (#89, ADR-0047).

Index

Constants

View Source
const (
	// Format is the archive layout version.
	Format = 1
	// MinPasswordLen of a backup password; the archive holds credentials.
	MinPasswordLen = 12
)

Variables

View Source
var ErrWrongPassword = errors.New("wrong password, or not a nerdui backup")

ErrWrongPassword means the archive could not be decrypted with the password.

Functions

func FileName

func FileName(t time.Time) string

FileName is the suggested name of an archive created at t.

func GitDir

func GitDir(dataDir string) string

GitDir is where Git stacks are cloned.

func ValidatePassword

func ValidatePassword(p string) error

ValidatePassword checks a backup password.

func Write

func Write(ctx context.Context, src Source, password string, w io.Writer) error

Write writes an encrypted archive of src to w.

Types

type Manifest

type Manifest struct {
	Format  int       `json:"format"`
	Created time.Time `json:"created"`
	Nerdui  string    `json:"nerdui"`
	Schema  int64     `json:"schema"`
	// DataDir and StacksDir of the source host: stack paths below them are moved to the
	// directories of the host that restores the archive.
	DataDir   string `json:"dataDir"`
	StacksDir string `json:"stacksDir"`
}

Manifest describes an archive.

func Restore

func Restore(ctx context.Context, r io.Reader, password string, t Target) (Manifest, error)

Restore decrypts an archive and puts its database, stacks and Git stacks in place. nerdui must not be running.

type Source

type Source struct {
	Store     *store.Store
	DataDir   string
	StacksDir string
	// KeyFile encrypts secrets in the database (#35); it is included when it exists.
	KeyFile string
}

Source is what a backup contains.

type Target

type Target struct {
	DataDir   string
	StacksDir string
	// KeyFile is where the key of secrets in the database is restored (#35).
	KeyFile string
	// Force replaces an existing database, stacks and Git stacks; they are kept next to
	// their place as <name>.before-restore-<time>.
	Force bool
	// Logf reports progress.
	Logf func(format string, args ...any)
}

Target is where an archive is restored.

Jump to

Keyboard shortcuts

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