# 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](https://tinyshed.org/tinystore/docs/guides/backup) explains how to use them, and the [Bun and Node](https://tinyshed.org/tinystore/docs/reference/bun/backup), [Python](https://tinyshed.org/tinystore/docs/reference/python/backup) and [Rust](https://tinyshed.org/tinystore/docs/reference/rust/backup) pages list the same API.

## Backup

```go
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

```go
type BackupOption func(*wire.BackupWrite)
```

BackupOption is what a backup takes beside every engine's files.

### Include

```go
func Include(paths ...string) BackupOption
```

Include takes these files of the program's, by their paths in the store's directory.

### IncludeEncryptionKey

```go
func IncludeEncryptionKey() BackupOption
```

IncludeEncryptionKey takes the store's encryption key, the zip not being encrypted.

## Store.Backup

```go
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")
```
