# dokploy_web_server_backup (Resource)

A scheduled backup of the Dokploy host. Dokploy dumps its own database and its configuration directory to an S3-compatible destination.

~> Dokploy lets more than one web-server backup exist. Each resource manages one backup. The provider does not run a backup on demand.

## Example Usage

```terraform
# Back up the Dokploy host every night. Dokploy dumps its own database and
# its configuration directory to the destination.
resource "dokploy_web_server_backup" "nightly" {
  destination_id  = dokploy_destination.backups.id
  cron_expression = "0 3 * * *"
  prefix          = "dokploy/"

  keep_latest_count = 14
}
```

```terraform
# Back up the Dokploy host to an S3 bucket. The destination and the backup
# are two resources. The backup refers to the destination by id.
resource "dokploy_destination" "host_backups" {
  name          = "host-backups"
  provider_name = "AWS"
  endpoint      = "https://s3.eu-west-1.amazonaws.com"
  bucket        = "dokploy-host-backups"
  region        = "eu-west-1"

  access_key_wo                = var.s3_access_key
  access_key_wo_version        = 1
  secret_access_key_wo         = var.s3_secret_access_key
  secret_access_key_wo_version = 1
}

resource "dokploy_web_server_backup" "host" {
  destination_id  = dokploy_destination.host_backups.id
  cron_expression = "0 3 * * *"
  prefix          = "dokploy/"

  keep_latest_count      = 14
  include_encryption_key = true
}
```

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

### Required

- `cron_expression` (String) Standard five-field cron expression, for example `0 3 * * *`.
- `destination_id` (String) Id of the `dokploy_destination` that receives the backups.
- `prefix` (String) Key prefix inside the destination bucket, for example `dokploy/`.

### Optional

- `enabled` (Boolean) Whether the backup runs. Defaults to `true`. Dokploy leaves this field null for a record from the API alone, which is neither on nor off.
- `include_encryption_key` (Boolean) Include the encryption key in the backup. Defaults to `true`, the value that Dokploy stores for a new backup. The provider always sends the field, because the Dokploy update endpoint stores `false` for an omitted field.
- `keep_latest_count` (Number) Number of backups to keep. Omit it to keep all of them.

### Read-Only

- `id` (String) Backup id.

## Import

Import is supported using the following syntax:

In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example:

```terraform
import {
  to = dokploy_web_server_backup.nightly
  id = "b1a2b3c4d5e6f7g8h9i0j"
}
```

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
terraform import dokploy_web_server_backup.nightly b1a2b3c4d5e6f7g8h9i0j
```