> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nanovm.dev.lithosai.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Save, restore, fork

> Checkpoint memory + disk, restore into new sandboxes, and fork live copies for parallel work.

## Save and restore

```python theme={null}
snap = sb.snapshot()                       # checkpoint memory + disk, VM keeps running
snap = sb.snapshot(wait_durable=True)      # block until it also survives node loss (seconds)
sb2  = nv.snapshots.restore(snap)          # NEW sandbox at exactly that point (~170 ms)
```

A snapshot is restorable the moment the call returns and **durable** (survives
the node it was born on) seconds later; `wait_durable=True` blocks for that.
`snapshot(leave_paused=True)` parks the vCPUs right after the checkpoint — the
next call wakes it in \~10–20 ms — the right shape for a snapshot-every-turn
agent loop that idles across model calls.

**Sharp edges:** restoring takes the snapshot's shape (cpus/memory are not
overridable at restore). Deleting a sandbox does not delete its snapshots.
Export (downloading a snapshot's bytes out of the platform) is experimental —
see the [HTTP API reference](/reference/http-api#snapshots-and-exports).

## Fork for parallel work

```python theme={null}
kids = sb.fork(4)      # 4 running siblings from ONE point in time (~120–150 ms total)
kid  = sb.fork()       # one
```

A fork is a live checkpoint + restore: children resume the parent's exact
processes and open files. Up to 4 per call at launch. Use one `fork(n)` call,
not n `fork()` calls — the fan-out takes a single checkpoint of the parent.

**Sharp edges:** external network connections are duplicated into every child
(each side thinks it owns the socket) — close connections you don't want
forked, or fork between commands, not mid-flight.
