# Backup

A backup is the whole store as one zip: every engine's files, each copied as
one moment of itself while the store keeps working, with a manifest of each
file's size and SHA-256. A restore puts it back into an empty directory,
checking every byte, or leaves nothing.

```ts
const backup = await store.backup('backups/chat-2026-10-19.zip') // { files, bytes, keyLeftOut }
```

```python
backup = await store.backup("backups/chat-2026-10-19.zip")  # Backup(files, bytes, key_left_out)
```

```go
backup, err := store.Backup(ctx, "backups/chat-2026-10-19.zip") // tinystore.Backup{Files, Bytes, KeyLeftOut}
```

```rust
let backup = store.backup().write("backups/chat-2026-10-19.zip")?;
```

```sh
tinystore backup ./data backups/chat-2026-10-19.zip
tinystore restore backups/chat-2026-10-19.zip ./restored
```

## What it guarantees

- A backup holds one moment of each engine while the store keeps working
  (contract BAK-01).
- A restore checks every byte against the manifest and the zip, writes only
  into an empty directory, and leaves nothing when it fails (contract
  BAK-02).
- The store's encryption key and the program's own files are left out unless
  asked for, and a backup without the key says so (contract BAK-03).
- A backup that fails leaves no zip and no snapshot (contract BAK-04).

## In these guides

| Page                                                                                   | Covers                                        |
| -------------------------------------------------------------------------------------- | --------------------------------------------- |
| [Restore](https://tinyshed.org/tinystore/docs/guides/backup/restore)                   | the command, Rust's `restore`, what it checks |
| [The encryption key](https://tinyshed.org/tinystore/docs/guides/backup/encryption-key) | `includeEncryptionKey`, a key kept apart      |

New to backups? [Keeping it](https://tinyshed.org/tinystore/docs/handbook/chat/keeping-it) in the
Handbook backs up every night with a schedule and restores on another
machine.

## Reference

[Bun and Node](https://tinyshed.org/tinystore/docs/reference/bun/backup) ·
[Python](https://tinyshed.org/tinystore/docs/reference/python/backup) ·
[Go](https://tinyshed.org/tinystore/docs/reference/go/backup) ·
[Rust](https://tinyshed.org/tinystore/docs/reference/rust/backup)
