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 ¶
- func Restore(ctx context.Context, dir string, archive io.ReaderAt, size int64) error
- func Write(ctx context.Context, store *tinystore.Store, w io.Writer) (err error)
- func WriteSnapshot(ctx context.Context, snapshot tinystore.Snapshot, created time.Time, ...) (err error)
- type Manifest
- type ManifestFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Restore ¶
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 ¶
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"`
}