# Sleep and wake

A branch you are not using does not need to run. Put it to sleep: its services stop, its data stays, and it uses no CPU or memory until you wake it.

## Sleep

```sh
omniarc arc branch sleep shop preview
```

```text
shop/preview asleep — data kept, compute stopped
```

## Wake

```sh
omniarc arc branch wake shop preview
```

Its services start again, from the data they stopped with. Like a deploy, a start gives every service up to [`ready_timeout_secs`](https://docs.omniarc.eu/reference/arc-yaml/ready-timeout-secs.md) to be ready. Containers that were running start again; a one-shot container that had already exited stays exited, as compose's `restart` rules say.

On the dashboard's arc page, each branch has a **Sleep** button while it is awake and a **Wake** button while it is asleep. `omniarc arc show shop` shows which branches are awake, in its `AWAKE` column. A key with the `member` role can sleep and wake branches.

## What sleeping saves

An asleep branch uses no CPU and no memory, and its awake time stops counting. Its data still takes room, so its storage counts as before. To stop that too, destroy the branch:

```sh
omniarc arc branch destroy shop preview
```

See [Costs](https://docs.omniarc.eu/guides/costs.md) for what is measured.

## How long an arc is kept

An arc that nobody uses for long enough is deleted, with all its branches and their data. Using it in any way resets the clock: a request to it, a wake, a branch or a deploy.

How long is set per arc, in the dashboard: open the arc and find **How long this arc is kept**, then enter a number of days, or `0` to keep it indefinitely. It needs the `admin` role. A shorter window is always allowed; a longer one, or `0`, only as far as your organization's own allowance goes, and a refusal says what that is. The same page shows when the arc was last used and, when a deletion is coming, its date.

Before an arc is deleted, its organization's owners get an email naming the arc and the date. Using the arc before then calls the deletion off.

A branch other than production is also deleted when nobody has used it for long enough, without an email first. Production goes only with its arc.

**Example: shop/arc.yaml**

```yaml
arc: shop
edge: { service: web, port: 3000 }
resources: { cpu: "1", memory: 1Gi, disk: 5Gi }
services:
  web:
    kind: web-service
    contains_pii: false
  db:
    kind: database
    contains_pii: true
    anonymize:
      engine: postgres
      database: shop
      user: shop
      rules:
        - { table: customers, column: email, transform: fake-email }
```
