backup

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package backup creates and restores tar.gz snapshots of the data directory (SQLite DB, certs, generated config, ACME account). The master state needed to reproduce a working panel lives entirely under the data dir.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPending

func ApplyPending(dataDir string) (applied bool, err error)

ApplyPending applies a staged restore (if any) over dataDir, then clears the staging area. Call it on boot before opening the database. No-op when nothing is staged. Re-downloadable assets not present in the backup (bin/, geo/) are left in place.

func Create

func Create(dataDir, out string) error

Create writes a gzip-compressed tar of dataDir to the named file.

func Restore

func Restore(file, dataDir string) error

Restore extracts a backup tarball into dataDir (which must exist).

func StageRestore

func StageRestore(file, dataDir string) error

StageRestore unpacks a backup into a staging area inside dataDir and marks it ready. The restore is applied by ApplyPending on the next boot, BEFORE the database is opened — so a live SQLite WAL can't checkpoint stale data back over the restored DB (which would silently revert the restore). On failure the live data is left untouched.

func WriteWithManifest

func WriteWithManifest(dataDir string, m Manifest, w io.Writer) error

WriteWithManifest streams a gzip-compressed tar of dataDir to w, prepending manifest.json as the first entry so inspectors can peek at it cheaply.

Types

type Manifest

type Manifest struct {
	Domain     string `json:"domain"`
	SecretPath string `json:"secret_path"`
	UserCount  int    `json:"user_count"`
	CreatedAt  string `json:"created_at"`
}

Manifest is written as manifest.json (the first tar entry) in every backup. It lets the operator preview what a backup contains before restoring.

func ReadManifest

func ReadManifest(r io.Reader) (Manifest, error)

ReadManifest reads the manifest.json entry from a backup tar.gz stream. It stops reading as soon as the manifest is found, so only a small prefix of a large archive needs to be decompressed.

Jump to

Keyboard shortcuts

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