# Backups

Backups are experimental. Endpoints, request and response formats, and behavior can change without notice.

A backup captures deployment storage volumes at a point in time through AWS EBS snapshots. Restore it to recover data or return to an earlier state after an upgrade.

[Diagnostic snapshots](/api/snapshots) capture runtime information for troubleshooting. Backups capture disk data for later restoration.

Use the Supervisor API, `{supervisor_url}`, for these requests.

Backups require AWS network storage and a Performance or Enterprise plan. Local NVMe SSD deployments do not support them.

Listing requires `deployment:read`. Creation, restoration, and deletion require `deployment:manage`.

Backup statuses: `pending`, `in_progress`, `completed`, `failed`, `deleting`

Backup types: `manual`, `scheduled`, `pre_upgrade`

Only one backup can run for a deployment at a time.

***

## List Backups

`GET {supervisor_url}/deployments/{deployment_id}/backups`

List all backups for the deployment.

```bash
curl {supervisor_url}/deployments/{deployment_id}/backups \
-H "ld-api-key: YOUR_API_KEY"
```

```json
[
  {
    "id": 1,
    "deployment_id": 611298765432109056,
    "node_id": 1,
    "name": "pre-migration",
    "backup_type": "manual",
    "status": "completed",
    "snapshot_ids": ["snap-0abc123def456789a"],
    "volume_ids": ["vol-0abc123def456789a"],
    "size_bytes": 53687091200,
    "region": "us-west-1",
    "remarks": null,
    "started_at": "2025-01-15T10:30:00Z",
    "completed_at": "2025-01-15T10:45:00Z",
    "expires_at": "2025-02-14T10:30:00Z",
    "created_at": "2025-01-15T10:30:00Z"
  }
]
```

`snapshot_ids` and `volume_ids` identify the underlying AWS resources for traceability.

## Create a Backup

`POST {supervisor_url}/deployments/{deployment_id}/backups`

Trigger an on-demand backup. Only one backup can be in progress per deployment at a time.

```bash
curl -X POST {supervisor_url}/deployments/{deployment_id}/backups \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "name": "pre-migration",
  "remarks": "Captured before schema migration",
  "expires_in_days": 30
}'
```

| Field | Required | Description |
| --- | --- | --- |
| `name` | Yes | Human-readable backup name |
| `node_id` | No | Specific node to back up. Omit to back up every node |
| `backup_type` | No | `manual` (default), `scheduled`, or `pre_upgrade` |
| `remarks` | No | Optional free-form description |
| `expires_in_days` | No | Auto-delete after this many days |

The endpoint returns `204 No Content`. The background operation progresses from `pending` to `in_progress` to `completed`.

## Restore from a Backup

`POST {supervisor_url}/deployments/{deployment_id}/backups/{backup_id}/restore`

Restore the deployment to the state captured in the backup. The deployment is stopped during the restore and restarted automatically.

```bash
curl -X POST {supervisor_url}/deployments/{deployment_id}/backups/{backup_id}/restore \
-H "ld-api-key: YOUR_API_KEY"
```

The endpoint returns `204 No Content`. Only one restore can run for a deployment at a time.

Before restoring, save a fresh backup if later writes must be kept. Restoration replaces current volumes and loses data written after the selected backup.

## Delete a Backup

`DELETE {supervisor_url}/deployments/{deployment_id}/backups/{backup_id}`

Delete a backup. Backups in `pending` or `in_progress` cannot be deleted - wait for them to finish first.

```bash
curl -X DELETE {supervisor_url}/deployments/{deployment_id}/backups/{backup_id} \
-H "ld-api-key: YOUR_API_KEY"
```

A successful request returns `204 No Content`.

- [Backups Guide](/deployments/backups): Backup types, plan limits, and retention
- [Snapshots API](/api/snapshots): Diagnostic node reports (separate feature)

Source: https://docs.laserdata.com/api/backups
