dump

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dump reads/writes awg-admin's boltdb as a portable JSON snapshot of every bucket's raw key/value pairs — the format shared by the in-app backup (Service.Backup / the desktop "Backup" button / the standalone GET /backup) and the standalone awg-migrate CLI, so a backup taken from one can be restored with the other. It's deliberately schema-agnostic: it copies bytes, not models, so it doesn't need to know anything about the application schema (and isn't tripped up by the historical bktUsers/bktInterfaces bucket-name mismatch in storage/boltdb). The binary format of the values is an internal implementation detail, not a stable cross-version contract — a dump is only guaranteed to restore into the same awg-admin version it was taken from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(db *bolt.DB, w io.Writer) error

Export writes a consistent snapshot of every bucket in db to w as indented JSON (bolt's db.View gives a point-in-time read transaction, so this is a safe hot backup while the database is in use).

func Import

func Import(db *bolt.DB, r io.Reader, force bool) error

Import reads a Dump from r and writes every key/value into db. With force false it aborts on the first key that already exists in the destination; with force true it overwrites.

Types

type Dump

type Dump struct {
	Buckets map[string]map[string]json.RawMessage `json:"buckets"`
}

Dump is the on-disk JSON shape: bucket name -> (hex-encoded key -> raw JSON value). Keys are hex-encoded rather than left as plain strings because several buckets (servers, interfaces, users) key their entries by raw 16-byte UUIDs, which aren't valid UTF-8/JSON string content as-is.

Jump to

Keyboard shortcuts

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