backup

package
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package backup writes every engine of a tinystore.Store into one zip, and restores it into an empty directory before the store opens. It is a package of its own so that archive/zip is linked only by programs that back up.

backup.zip
├── manifest.json    format, time, and each file's engine, schema, size and sha256
├── metrics.db
├── records.db
└── sql/app.db

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Restore

func Restore(ctx context.Context, dir string, archive io.ReaderAt, size int64) error

Restore unpacks a backup into dir, which must be empty or absent: it runs before tinystore.Open, never on an open store. Every file is checked against the manifest's size and sha256; on any failure nothing is left in dir.

func Write

func Write(ctx context.Context, store *tinystore.Store, w io.Writer) (err error)

Write copies every engine's file while the store keeps working, and writes the copies and their manifest to w as one zip.

func WriteSnapshot

func WriteSnapshot(ctx context.Context, snapshot tinystore.Snapshot, created time.Time, w io.Writer) (err error)

WriteSnapshot writes the copies a snapshot holds and their manifest to w as one zip, as Write does, for a snapshot its caller added copies to: a server adds the databases no client opened. created is the time the manifest records. The snapshot stays the caller's to remove.

Types

type Manifest

type Manifest struct {
	Format  int            `json:"format"`
	Created time.Time      `json:"created"`
	Files   []ManifestFile `json:"files"`
}

type ManifestFile

type ManifestFile struct {
	tinystore.SnapshotFile
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
}

Jump to

Keyboard shortcuts

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