siteexport

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: 8 Imported by: 0

Documentation

Overview

Package siteexport extracts a single site from a full UniFi backup and repackages it as an importable .unf site export.

A UniFi MongoDB dump is a command stream: a document {__cmd:"select", collection:"X"} selects a collection, and the documents that follow are its rows until the next select. Per-site collections carry a site_id string that references the owning site's _id. Exporting a site means emitting that site's row plus, for each per-site collection, only the rows whose site_id matches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extra

type Extra struct {
	Name string
	Data []byte
}

Extra is an extra file (floorplan, portal asset) copied into the export.

type Parsed

type Parsed struct {
	Sites []Site
	// contains filtered or unexported fields
}

Parsed is the decoded command stream of a full backup's MongoDB dump.

func Parse

func Parse(dump []byte) (*Parsed, error)

Parse decodes a decompressed MongoDB dump (the raw concatenated-BSON stream) into its sites and per-collection rows.

func (*Parsed) BuildUnf

func (p *Parsed) BuildUnf(site Site, version string, timestampMillis int64, extras []Extra) ([]byte, error)

BuildUnf assembles and encrypts an importable .unf for the given site. version is the source controller version; timestampMillis stamps the export; extras are site-scoped files already remapped to "sites/<name>/..." paths.

func (*Parsed) FindSite

func (p *Parsed) FindSite(selector string) (Site, error)

FindSite returns the site whose ID or name matches selector, or an error naming the available sites when there is no unambiguous match.

type Site

type Site struct {
	ID     string
	Name   string
	Desc   string
	Hidden bool
	// contains filtered or unexported fields
}

Site describes a site discovered in a full backup.

Jump to

Keyboard shortcuts

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