extract

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package extract turns an encrypted UniFi backup file into a uniform, inspectable container of named entries.

It supports the two UniFi backup container formats:

  • .unf site export or classic controller autobackup. AES-128-CBC (static key + IV) -> ZIP archive.

  • .unifi UniFi OS / UCore console full backup. AES-256-CBC (static key, IV = first 16 bytes) -> gzip -> tar archive.

After decryption both are reduced to a list of Entry values so callers can treat MongoDB dumps, system properties, and Postgres files the same way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	Kind         Kind
	Container    []byte  // the raw decrypted container (a .zip or .tar)
	ContainerExt string  // ".zip" or ".tar"
	Entries      []Entry // files contained within
}

Backup is a fully decrypted, unpacked UniFi backup.

func Open

func Open(path string, forceKind Kind) (*Backup, error)

Open reads and decrypts the backup at path. The format is chosen by file extension; pass forceKind to override detection (empty string = auto).

func (*Backup) Find

func (b *Backup) Find(candidates ...string) *Entry

Find returns the first entry whose name matches any of the candidate paths, or nil if none match. Candidates are tried in order.

func (*Backup) MongoDump

func (b *Backup) MongoDump() ([]byte, error)

MongoDump locates the gzipped BSON database dump and returns the raw (decompressed) BSON stream of concatenated documents.

type Entry

type Entry struct {
	Name string
	Data []byte
}

Entry is a single file inside a decrypted backup container.

type Kind

type Kind string

Kind identifies the backup container format.

const (
	// KindUnf is a .unf site export or classic autobackup (AES-128 -> zip).
	KindUnf Kind = "unf"
	// KindUnifi is a .unifi console backup (AES-256 -> gzip -> tar).
	KindUnifi Kind = "unifi"
)

Jump to

Keyboard shortcuts

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