# dokploy_backup (Data Source)

Looks up a database backup schedule of a database or compose service that already exists in Dokploy:

```terraform
data "dokploy_backup" "nightly" {
  service_id   = data.dokploy_postgres.main.id
  service_type = "postgres"
  prefix       = "nightly"
}
```

~> **The data source does not expose the compose database credentials.** The `compose_database_*` credentials exist exists on the `dokploy_backup` resource, but not here, by design.

~> Dokploy does not enforce uniqueness for this record. If two backup records match the lookup attributes, this data source fails instead of a guess. Look the record up by `id` in that case.

## Example Usage

```terraform
data "dokploy_backup" "example" {
  id = "your-backup-id"
}

data "dokploy_backup" "nightly" {
  service_id   = data.dokploy_postgres.main.id
  service_type = "postgres"
  prefix       = "nightly"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `id` (String) Backup id. Set it for a lookup by id, or leave it unset and set `service_id` with the distinguishing attributes.
- `prefix` (String) Prefix of the backup files in the destination.
- `service_id` (String) Id of the service that owns the backup. Set it with `service_type` and `prefix`.
- `service_type` (String) Type of the service: `postgres`, `mysql`, `mariadb`, `mongo`, `libsql` or `compose`.

### Read-Only

- `app_name` (String) Internal name of the backup.
- `compose_database_type` (String) Database engine of a compose service, or null for a database service.
- `cron_expression` (String) Cron expression of the backup schedule.
- `database` (String) Name of the database to back up.
- `destination_id` (String) Id of the destination that stores the backup.
- `enabled` (Boolean) Whether the backup runs.
- `include_encryption_key` (Boolean) Whether the backup includes the encryption key.
- `keep_latest_count` (Number) Number of backups to keep, or null to keep all.
- `service_name` (String) Compose service name, or null.