CTRLctrl docs

Volumes

An app's own disk is wiped on every deploy. A volume is a disk that keeps its data. It belongs to one app, is mounted at one path, and survives redeploys, rollbacks, env changes and host reboots.

Before you add one, know what it costs you:

  • A volume lives on one node and is not backed up. If that node's disk dies, the data is gone. Take snapshots (below) of anything you can't lose.
  • An app with a volume can't move to another node.
  • An app with a volume has a short outage on every deploy. The old VM stops before the new one boots, because two VMs must never mount one filesystem. Your app gets SIGTERM and 5 seconds to finish.
  • Previews never get a volume. A rollback changes your code, not the data on the volume.
  • The mount hides whatever your image has at that path.

An app has at most one volume.

Create a volume#

In the dashboard, open your app, go to the storage tab and find the ctrl volume panel. Fill in the name, mount path and size (GB), then click + create volume. The form starts with data, /data and 10 GB.

With the API:

curl -X POST https://api.getctrl.dev/v1/volumes \
  -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "app_id": "my-api", "name": "uploads", "mount_path": "/data", "size_mb": 10240 }'

A running app restarts with the volume mounted. A stopped app stays stopped and gets the volume at its next deploy.

The answer is 201:

{
  "volume": { "id": "vol-...", "name": "uploads", "app_id": "my-api", "node_id": "us-1", "mount_path": "/data", "size_mb": 10240, "status": "ready", "restore_id": null, "restore_error": null, "created_at": "..." },
  "redeployed": true,
  "app_status": "running"
}

If redeployed is false, error says why the app wasn't restarted. The volume still exists. app_status says whether the app is running now.

Names#

A name is lowercase letters, digits and dashes, starts with a letter or digit, and is at most 63 characters. Otherwise you get 400 with name must be lowercase letters, digits and dashes.

Mount path rules#

The mount path must:

  • be absolute, such as /data or /var/lib/app;
  • not be /;
  • not be under /proc, /sys, /dev or /etc;
  • have no . or .. parts;
  • use only letters, digits, ., _ and - in each part;
  • be at most 255 characters.

Otherwise you get 400 with mount_path must be absolute, not /, not under /proc, /sys, /dev or /etc, with no ...

Size limits#

size_mb is a whole number from 1024 (1 GB) to 16777216 (16 TB). Otherwise you get 400 with size_mb must be a whole number from 1024 to 16777216.

A volume also has to fit your blocks. One block holds 30 GB of disk. You get 402 when:

  • you have no blocks (no blocks -- buy blocks on your account page first);
  • the volume alone is bigger than all your blocks hold;
  • your apps, volumes and snapshots already really use the disk your blocks hold.

Your volumes' sizes may add up past your blocks. What is capped is the disk you really use.

The node needs room too. If it has none, you get 409 with <node> has no room for <size>MB more in volumes.

Other errors#

Status Error
404 app not found
400 a preview cannot have a volume
409 this app already has a volume
503 agent unreachable: delete this volume and try again

If creating doesn't finish, the volume shows as not finished in the dashboard, and deploys of the app are refused. Delete the volume and create it again.

See your volumes#

curl https://api.getctrl.dev/v1/volumes?app_id=my-api \
  -H "Authorization: Bearer $CTRL_API_KEY"

Leave out app_id to list every volume on your account. GET /v1/volumes/:id returns one volume, plus allocated_mb: the disk reserved for it on the node, which is its whole size. It's null if the node didn't answer.

The node doesn't read your files, so it can't tell you how full a volume is. Run df inside your app for that.

Grow a volume#

Volumes only grow. They never shrink.

In the dashboard, enter the new size in GB and click grow and restart.

With the API:

curl -X PATCH https://api.getctrl.dev/v1/volumes/vol-... \
  -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "size_mb": 20480 }'

The new size must be more than the current one, or you get 400 with volumes only grow: size_mb must be more than <size>. The same size limits and block checks apply as when you create a volume.

A running app restarts, and the filesystem grows to the new size as the app boots. A stopped app grows at its next deploy.

If the node runs out of room during the restart, the app still starts, at the old size. The answer's error then says the app restarted, but the volume is still <size> MB: <node> has no room for the rest. If the filesystem itself can't grow, the app also starts at the old size, and its log says so. See logs and metrics.

Detach and reattach#

Detaching frees a volume from its app and keeps the data. The volume stays on its node and still counts against your disk.

In the dashboard, click detach and restart. With the API:

curl -X POST https://api.getctrl.dev/v1/volumes/vol-.../detach \
  -H "Authorization: Bearer $CTRL_API_KEY"

A running app stops and restarts without the volume. A stopped app stays stopped. The volume's app_id becomes null.

You can't delete an app that has a volume: DELETE /v1/apps/:app_id answers 409. Detach the volume (or delete it) first.

Attach to another app#

A detached volume can attach to any of your apps that:

  • runs on the same node as the volume, since the data is a file on that node's disk and doesn't move;
  • has no volume of its own;
  • is not a preview.

In the dashboard, detached volumes are listed in the ctrl volume panel of every app. An app on the volume's node, with no volume, shows an attach button. With the API:

curl -X POST https://api.getctrl.dev/v1/volumes/vol-.../attach \
  -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "app_id": "my-worker" }'

A running app restarts with the volume mounted at the volume's mount path. A stopped app gets it at its next deploy.

Status Error
400 app_id is required
409 this volume is attached to <app>: detach it first
409 this app already has a volume
409 volume <name> is on <node> and <app> on <node>: a volume's data stays on its node, so it attaches only to an app there

Snapshots#

A snapshot is a compressed copy of a volume, stored in Cloudflare R2. Snapshots are taken only when you ask. There is no schedule.

Take a snapshot#

In the dashboard, click take snapshot. With the API:

curl -X POST https://api.getctrl.dev/v1/volumes/vol-.../snapshots \
  -H "Authorization: Bearer $CTRL_API_KEY"

Your app stops while the node copies the volume, so nothing writes to it mid-copy. It starts again once the copy exists. The upload to R2 runs after that, with your app back up. The answer is 202, with the snapshot and app_status.

A snapshot is pending until it's uploaded, then ready. If it fails, it's failed and error says why.

List a volume's snapshots, newest first:

curl https://api.getctrl.dev/v1/volumes/vol-.../snapshots \
  -H "Authorization: Bearer $CTRL_API_KEY"

Each has id, volume_id, status, size_bytes, error and created_at.

The limit of 7#

A volume keeps at most 7 snapshots. Failed ones don't count. At 7 you get 409 with volume <name> has 7 snapshots, the most it keeps: delete one first.

Snapshots, disk and blocks#

Snapshots count against your disk. Once a snapshot is ready, its compressed size counts in the disk you really use, alongside your apps and volumes.

To take a snapshot, the volume's full size must fit your blocks, and your real disk use must be under what your blocks hold. Otherwise you get 402.

Restore a snapshot#

A restore replaces all the data on the volume with the snapshot's. What is there now is lost.

The volume's app must be stopped. If it's running, you get 409 with stop <app> first: a restore replaces all the data on its volume. A detached volume can be restored at any time.

Stopping an app yourself is coming soon (see lifecycle). Until then, you can restore into a running app's volume in three steps:

  1. Detach the volume.
  2. Restore the snapshot into it.
  3. Attach it again.

In the dashboard, click restore... next to a ready snapshot and confirm. With the API:

curl -X POST https://api.getctrl.dev/v1/volumes/vol-.../snapshots/snap-.../restore \
  -H "Authorization: Bearer $CTRL_API_KEY"

The answer is 202 with { "restoring": "snap-..." }. While it runs, the volume's restore_id is set and deploys wait. Your app gets the restored data when it next starts.

If a restore fails, the data stays as it was and the volume's restore_error says why.

You can't restore while a snapshot of the volume is being taken, or while another restore runs.

Delete a snapshot#

In the dashboard, click delete... next to a snapshot and confirm. There is no undo. With the API:

curl -X DELETE https://api.getctrl.dev/v1/volumes/vol-.../snapshots/snap-... \
  -H "Authorization: Bearer $CTRL_API_KEY"

You can't delete a snapshot that is still being taken, or one that is being restored.

Delete a volume#

Deleting a volume destroys it and all its data, and all its snapshots too. There is no undo.

In the dashboard, type the volume's name and click delete volume. With the API, pass the name as confirm:

curl -X DELETE "https://api.getctrl.dev/v1/volumes/vol-...?confirm=uploads" \
  -H "Authorization: Bearer $CTRL_API_KEY"

Without the right name you get 400 with pass ?confirm=<volume name> to delete it and all its data.

A running app stops, and restarts without the volume. You can't delete a volume while a snapshot or restore of it is running: you get 409 with a snapshot or restore of this volume is running: wait for it to finish.

This is the only way a volume is deleted. Deleting an app never deletes its volume.