# Persistence

Daytona sandboxes are persistent by default. Stopping a sandbox does not destroy it: the sandbox keeps its identity, its filesystem, and its configuration, and can be started again at any point with all files, installed packages, and repositories intact. A sandbox is only deleted when you delete it, mark it as [ephemeral](/content/docs/en/sandboxes#ephemeral-sandboxes/index.html), or set an [auto-delete interval](/content/docs/en/sandboxes#auto-delete-interval/index.html).

Persistence operates at three layers:

| **Layer** | **What is preserved** | **Mechanisms** |
| --- | --- | --- |
| Filesystem | Files, installed packages, cloned repositories, build artifacts | • [**Stop / start**](/content/docs/en/sandboxes#stop-sandboxes/index.html)<br> • [**Archive**](/content/docs/en/sandboxes#archive-sandboxes/index.html)<br> • [**Cold snapshots**](/content/docs/en/snapshots#create-snapshot-from-sandbox/index.html) |
| Memory | Running processes, open connections, loaded application state | • [**Pause / resume**](/content/docs/en/sandboxes#pause--resume-sandboxes/index.html)<br> • [**Hot snapshots**](/content/docs/en/snapshots#create-snapshot-from-sandbox/index.html)<br> • [**Fork**](/content/docs/en/sandboxes#fork-sandboxes/index.html) |
| External storage | Data that outlives any single sandbox | • [**Volumes**](/content/docs/en/volumes/index.html)<br> • [**Mount external storage**](/content/docs/en/mount-external-storage/index.html) |

The diagram demonstrates [VM (Linux VM and Windows) sandbox](/content/docs/en/sandboxes#vm-sandboxes/index.html) states and transitions with [filesystem](/content/docs/en/persistence/#filesystem-persistence/index.html) and [memory](/content/docs/en/persistence/#memory-persistence/index.html) persistence. Container sandboxes preserve the filesystem across stop and start, and do not support pause/resume; memory is cleared on every stop.

## Filesystem persistence

Filesystem persistence keeps the contents of a sandbox’s disk: files, installed packages, cloned repositories, and build artifacts. A sandbox with a preserved filesystem starts with its environment intact, with nothing to reinstall or rebuild.

Sandboxes preserve their filesystem across **stop and start** cycles, **archive**, and **snapshots created from a sandbox (cold snapshots)**. Sandbox classes differ in where and how the preserved filesystem is stored while the sandbox is stopped:

| **Sandbox class** | **Filesystem persistence** |
| --- | --- |
| Container | Filesystem is preserved through [**stop / start**](/content/docs/en/sandboxes#stop-sandboxes/index.html): it stays on the runner and counts against disk quota while stopped. [**Archive**](/content/docs/en/sandboxes#archive-sandboxes/index.html) moves it to object storage and frees the quota; starting an archived sandbox restores it. Use [**cold snapshots**](/content/docs/en/snapshots#create-snapshot-from-sandbox/index.html) to capture the filesystem. |
| VM sandboxes <br> (Linux VM and Windows) | Filesystem is preserved through [**stop / start**](/content/docs/en/sandboxes#stop-sandboxes/index.html): stopping offloads it to nearby storage and releases disk quota, starting restores it. Archive is not needed. Use [**cold snapshots**](/content/docs/en/snapshots#create-snapshot-from-sandbox/index.html) to capture the filesystem. |
| GPU | Ephemeral by design: deleted on stop, filesystem is not preserved. Use [**volumes**](/content/docs/en/volumes/index.html) to persist results. |

```python
from daytona import Daytona

daytona = Daytona()

sandbox = daytona.create()

# Write state to the filesystem

sandbox.fs.upload_file(b"intermediate results", "results.txt")

# Stop clears memory; the filesystem is preserved on the runner

sandbox.stop()

# Start returns the filesystem exactly as it was

sandbox.start()

response = sandbox.process.exec("cat results.txt")

print(response.result)  # intermediate results
```

## Memory persistence

Memory persistence keeps the runtime state of a sandbox: running processes, open connections, and everything loaded in RAM. A sandbox with preserved memory continues from the point it was frozen, with processes still running, instead of starting from a clean boot.

Sandboxes preserve their memory across **pause and resume** cycles, **snapshots created from a sandbox (hot snapshots)**, and **forks**. Memory state is cleared on every stop. Sandbox classes differ in whether memory can be preserved without keeping the sandbox running:

| **Sandbox class** | **Memory persistence** |
| --- | --- |
| Container | Memory persists only while the sandbox is running. Set the [**auto-stop interval**](/content/docs/en/sandboxes#auto-stop-interval/index.html) to `0` to run indefinitely, or relaunch processes after each start. Pause is not supported. |
| VM sandboxes <br> (Linux VM and Windows) | Memory is preserved through [**pause / resume**](/content/docs/en/sandboxes#pause--resume-sandboxes/index.html): pausing freezes the VM with memory intact, resuming continues all processes from the point they were frozen. Use [**hot snapshots**](/content/docs/en/snapshots#create-snapshot-from-sandbox/index.html) or [**forks**](/content/docs/en/sandboxes#fork-sandboxes/index.html) to capture memory. |
| GPU | Ephemeral by design: deleted on stop, and memory is not preserved. Use [**volumes**](/content/docs/en/volumes/index.html) to persist results of a GPU sandbox. |

```python
from daytona import Daytona

daytona = Daytona()

sandbox = daytona.create(CreateSandboxFromSnapshotParams(snapshot="daytona-vm-small"))

# Launch a process that holds state in memory

sandbox.process.create_session("server")

sandbox.process.execute_session_command("server", SessionExecuteRequest(

command="python3 -m http.server 8000",

run_async=True,
))

# Pause freezes the VM with filesystem and memory intact

sandbox.pause()

# Resume continues all processes from the point they were frozen

sandbox.start()

response = sandbox.process.exec("curl -s http://localhost:8000")

print(response.result)  # the server is still running
```

## Persistence beyond a sandbox

Filesystem and memory persistence are tied to a single sandbox: deleting the sandbox deletes its state. To persist state beyond the sandbox itself, capture it as a **snapshot**, duplicate it into an independent sandbox with a **fork**, or store data outside any sandbox in a **volume**.

### Snapshots from a sandbox

[Snapshots created from a sandbox](/content/docs/en/snapshots#create-snapshot-from-sandbox/index.html) capture and persist the sandbox’s current state, including the filesystem, installed packages, dependencies, and settings. The snapshot saves the state so you can restore it later, and any number of new sandboxes can start from the same snapshot. For snapshots built from an image or Dockerfile, which define a base environment rather than persist an existing sandbox, see [snapshots](/content/docs/en/snapshots/index.html).

## Forks

[Forking](/content/docs/en/sandboxes#fork-sandboxes/index.html) duplicates a VM sandbox’s filesystem and memory into a new, fully independent sandbox. Use forks to branch a live environment: run divergent experiments from the same state, test a risky change without touching the original, or hand each agent in a fleet an identical starting point.

### Volumes

[Volumes](/content/docs/en/volumes/index.html) are S3-backed mounts that persist independently of any sandbox. Data written to a mounted volume survives sandbox deletion and is readable from other sandboxes that mount the same volume. Use volumes for datasets, model weights, build caches, and per-user or per-tenant data scoped with a `subpath`. For data already in your own object storage, [mount external storage](/content/docs/en/mount-external-storage/index.html) directly instead of copying it in.
