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

# Persistence

> What a Devbox keeps when it stops, its snapshots, and ephemeral Devboxes.

A Devbox keeps its disk every time it stops, whether you stop it, it reaches its [idle timeout](https://namespace.so/docs/devbox/lifecycle.md#idle-timeout), or it hits its [maximum duration](https://namespace.so/docs/devbox/lifecycle.md#maximum-duration). When it starts again, its files are intact, so your agent can pick up where it left off. Each stop also saves a [snapshot](#snapshots) of the disk, so you can start from an earlier version later.

## What's kept and what ends

| | After a stop |
| - | - |
| Files on disk | Kept |
| [Command output](https://namespace.so/docs/devbox/exec.md#streaming-logs) | Kept until you delete the Devbox |
| [Task markers](https://namespace.so/docs/devbox/long-running-tasks.md#task-markers) | Kept |
| [Services](https://namespace.so/docs/devbox/services.md) | Start again on the next start. A service you stopped stays stopped |
| [Background commands](https://namespace.so/docs/devbox/exec.md#detached-executions) | End |

## Start again after a stop

Running a command, connecting, or using files from the SDK starts a stopped Devbox, so you rarely need to start it by hand. On start, the Devbox brings its [services](https://namespace.so/docs/devbox/services.md) and [blueprint sessions](https://namespace.so/docs/devbox/blueprint.md#sessions) back up. The [init script](https://namespace.so/docs/devbox/blueprint.md#init-script) doesn't run again. It runs only when the Devbox is first created.

## Snapshots

Each stop saves a snapshot of the disk. Each snapshot is a new version, such as V1, V2, and V3, and stores only what changed since the version before it.

* A running Devbox can't be snapshotted.
* Snapshots cover the disk only. Memory and running processes aren't saved.
* Snapshots exist only as long as the Devbox does.

> [!NOTE]
>
> Snapshots are available on Linux and macOS Devboxes, not yet on Windows.

### List a Devbox's snapshots

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import {
  createClient,
  createRegionTransport,
  loadDefaults,
} from "@namespacelabs/sdk";
import { DevBoxService } from
  "@namespacelabs/sdk/proto/namespace/private/devbox/devbox_pb";

const devboxApi = createClient(DevBoxService, createRegionTransport("iad", {
  tokenSource: loadDefaults,
  baseUrl: "https://private-api.iad.namespaceapis.com",
}));

const { snapshots } = await devboxApi.listSnapshots({ idOrName: "my-devbox" });
```

The newest snapshot comes first. Each one has an ID and the time it was taken.

### Start from an earlier snapshot

Starting a Devbox uses its latest snapshot. Pass a snapshot ID to start from an earlier version instead, for example to undo changes your agent made. Later versions are kept, and the next stop saves a new one.

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
await devboxApi.activate({ name: "my-devbox", fromSnapshotId: "SNAPSHOT_ID" });
```

## Ephemeral Devboxes

If nothing needs to survive, turn on ephemeral to create a Devbox for a single run, such as an agent task or a CI job. When it stops, including on idle timeout or maximum duration, its disk is deleted.

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
devbox create --name scratch --image builtin:default --size m --ephemeral
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const devbox = await client.devboxes.create({
  name: "scratch",
  imageName: "builtin:default",
  size: "m",
  ephemeral: true,
  // Or keep its name and settings for at least an hour after it stops:
  // ephemeral: { stoppedRetentionMs: 60 * 60_000 },
});
```

Copy out anything you need with [`devbox download`](https://namespace.so/docs/reference/devbox-cli/download) before it stops. To make every Devbox from a blueprint ephemeral, set it on the [blueprint](https://namespace.so/docs/devbox/blueprint.md#ephemeral).

A stopped ephemeral Devbox keeps its name and settings for a while, so starting it again gives you a fresh disk. After that, the Devbox is gone.

> [!NOTE]
>
> **Windows:** Devboxes are ephemeral only during early access.

## Related

* [Lifecycle](https://namespace.so/docs/devbox/lifecycle.md) to create, stop, start, and delete Devboxes.
* [Run commands](https://namespace.so/docs/devbox/exec.md) for command output and background commands.
* [Long running tasks](https://namespace.so/docs/devbox/long-running-tasks.md) to keep a Devbox awake while work runs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.