backup

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const FormatVersion = 1

Variables

This section is empty.

Functions

func DecodeJSONL

func DecodeJSONL[T any](plaintext []byte, out *[]T) error

func DecryptShard

func DecryptShard(ciphertext []byte, identityPath string) ([]byte, error)

func DecryptShardFile

func DecryptShardFile(cfg Config, shard ShardEntry) ([]byte, error)

func EncodeJSONL

func EncodeJSONL(rows any) ([]byte, int, error)

func EncryptShard

func EncryptShard(plaintext []byte, recipients []string) ([]byte, string, error)

func EnsureIdentity

func EnsureIdentity(path string) (string, error)

func EquivalentManifest

func EquivalentManifest(a, b Manifest) bool

func RecipientFromIdentity

func RecipientFromIdentity(path string) (string, error)

func RemoveStaleShards

func RemoveStaleShards(repo string, shards []ShardEntry) error

func ResolveShardPath

func ResolveShardPath(repo, rel string) (string, error)

func SHA256Hex

func SHA256Hex(data []byte) string

func WriteManifest

func WriteManifest(repo string, manifest Manifest) error

Types

type Config

type Config struct {
	Repo       string
	Identity   string
	Recipients []string
}

type DecodedShard

type DecodedShard struct {
	Entry     ShardEntry
	Plaintext []byte
}

func ReadSnapshot

func ReadSnapshot(cfg Config, manifest Manifest) ([]DecodedShard, error)

type Manifest

type Manifest struct {
	Format     int            `json:"format"`
	Encrypted  bool           `json:"encrypted"`
	Exported   time.Time      `json:"exported"`
	Recipients []string       `json:"recipients,omitempty"`
	Counts     map[string]int `json:"counts"`
	Shards     []ShardEntry   `json:"shards"`
}

func ReadManifest

func ReadManifest(repo string) (Manifest, error)

func WriteSnapshot

func WriteSnapshot(ctx context.Context, cfg Config, shards []Shard, old Manifest) (Manifest, error)

func (Manifest) Entry

func (m Manifest) Entry(path string) (ShardEntry, bool)

type Shard

type Shard struct {
	Table string
	Path  string
	Rows  any
}

type ShardEntry

type ShardEntry struct {
	Table  string `json:"table"`
	Path   string `json:"path"`
	Rows   int    `json:"rows"`
	SHA256 string `json:"sha256"`
	Bytes  int64  `json:"bytes"`
}

func WriteShard

func WriteShard(cfg Config, old Manifest, table, rel string, plaintext []byte, rows int, reuseEncrypted bool) (ShardEntry, error)

Jump to

Keyboard shortcuts

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