backup

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 17 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backup

func Backup(opts BackupOptions) (string, error)

Backup creates a compressed archive of DBPath, ConfigPath, and StateDir in OutputDir. It returns the full path of the created archive file. On failure it removes any partially-written output and returns an error.

func DecryptFile

func DecryptFile(src, dst, password string) error

DecryptFile reads an encrypted file produced by EncryptFile and writes the plaintext to dst. Returns an error containing "incorrect password or corrupted file" if decryption fails.

func EncryptFile

func EncryptFile(src, dst, password string) error

EncryptFile reads src, encrypts it with AES-256-GCM using a key derived from password via scrypt, and writes [salt(32) | nonce(12) | ciphertext] to dst.

func PackTarGz

func PackTarGz(archivePath, srcDir string) error

PackTarGz creates a gzip-compressed tar archive at archivePath from the contents of srcDir. File paths inside the archive are relative to srcDir.

func Restore

func Restore(opts RestoreOptions) error

Restore extracts a backup archive and copies files to their configured locations. It returns an error if data already exists at the destinations and Force is false, or if the archive is encrypted and Password is empty/wrong.

func SHA256File

func SHA256File(path string) (string, error)

SHA256File returns the hex-encoded SHA256 digest of the file at path.

func UnpackTarGz

func UnpackTarGz(archivePath, dstDir string) error

UnpackTarGz extracts a gzip-compressed tar archive into dstDir. For security, path traversal entries (containing "..") are rejected.

func WriteManifest

func WriteManifest(path string, m Manifest) error

WriteManifest serialises m as indented JSON to path.

Types

type BackupOptions

type BackupOptions struct {
	DBPath     string // path to openbee.db
	ConfigPath string // path to config.yaml
	StateDir   string // path to ~/.openbee/
	OutputDir  string // directory where the archive is written
	AppVersion string // openbee binary version (for manifest)
	Password   string // if non-empty, encrypt the archive
}

BackupOptions configures a Backup call.

type FileEntry

type FileEntry struct {
	Path   string `json:"path"`
	SHA256 string `json:"sha256"`
}

FileEntry records the archive-relative path and SHA256 checksum of one file.

type Manifest

type Manifest struct {
	Version        string      `json:"version"`
	OpenbeeVersion string      `json:"openbee_version"`
	CreatedAt      string      `json:"created_at"`
	Files          []FileEntry `json:"files"`
}

Manifest describes the contents of a backup archive.

func ReadManifest

func ReadManifest(path string) (Manifest, error)

ReadManifest deserialises a manifest from path.

type RestoreOptions

type RestoreOptions struct {
	ArchivePath string // path to .tar.gz or .tar.gz.enc
	DBPath      string // destination for openbee.db
	ConfigPath  string // destination for config.yaml
	StateDir    string // destination for ~/.openbee/
	AppVersion  string // running openbee version (for compatibility check)
	Force       bool   // overwrite existing data without error
	Password    string // required when ArchivePath ends in .enc
}

RestoreOptions configures a Restore call.

Jump to

Keyboard shortcuts

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