Reference / Backup API for Go
Backup API for Go
Every public type, function and constant of the Backup engine in tinyshed.org/tinystore, generated from its source. The Backup guide explains how to use them, and the Bun and Node, Python and Rust pages list the same API.
Backup
type Backup struct {
// Files are the files, the engines' and those it was told to take.
Files int
// Bytes are their bytes, the zip's own fields aside.
Bytes int64
// KeyLeftOut says the store seals values with an encryption key the
// backup does not hold: they open with that key alone.
KeyLeftOut bool
}Backup is what a backup holds.
BackupOption
type BackupOption func(*wire.BackupWrite)BackupOption is what a backup takes beside every engine's files.
Include
func Include(paths ...string) BackupOptionInclude takes these files of the program's, by their paths in the store's directory.
IncludeEncryptionKey
func IncludeEncryptionKey() BackupOptionIncludeEncryptionKey takes the store's encryption key, the zip not being encrypted.
Store.Backup
func (s *Store) Backup(ctx context.Context, path string, opts ...BackupOption) (Backup, error)Backup writes a backup of every engine of the store to path as one zip, made while the store keeps working, which tinystore restore takes back into an empty directory. It is written beside path and renamed once whole, so that a backup that fails leaves no zip; a connection lost on the way makes it again from its start.
backup, err := store.Backup(ctx, "backup-2026-10-13.zip")