Documentation
¶
Index ¶
- func Backup(opts BackupOptions) (string, error)
- func DecryptFile(src, dst, password string) error
- func EncryptFile(src, dst, password string) error
- func PackTarGz(archivePath, srcDir string) error
- func Restore(opts RestoreOptions) error
- func SHA256File(path string) (string, error)
- func UnpackTarGz(archivePath, dstDir string) error
- func WriteManifest(path string, m Manifest) error
- type BackupOptions
- type FileEntry
- type Manifest
- type RestoreOptions
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 ¶
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 ¶
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 ¶
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 ¶
SHA256File returns the hex-encoded SHA256 digest of the file at path.
func UnpackTarGz ¶
UnpackTarGz extracts a gzip-compressed tar archive into dstDir. For security, path traversal entries (containing "..") are rejected.
func WriteManifest ¶
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 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 ¶
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.