skip to content
wihan.dev
view as markdown
browse the dokploy docs

dokploy_volume_backup (Resource)

A scheduled archive of a Docker volume to an S3-compatible destination.

A volume backup copies the contents of the volume as they are, so it works for any service with a volume. That includes Redis, which dokploy_backup cannot cover because Dokploy has no logical dump for it.

Example Usage

terraform
# Nightly archive of the uploads volume of an application.
resource "dokploy_volume_backup" "uploads" {
  name            = "web-uploads-nightly"
  service_id      = dokploy_application.web.id
  service_type    = "application"
  volume_name     = "web-uploads"
  prefix          = "volumes/web/"
  cron_expression = "0 4 * * *"
  destination_id  = dokploy_destination.backups.id

  keep_latest_count = 14
}

# Redis has no logical dump in Dokploy, so a volume backup is the only way
# to capture it. dokploy_backup rejects a Redis parent at plan time.
resource "dokploy_volume_backup" "cache" {
  name            = "cache-nightly"
  service_id      = dokploy_redis.cache.id
  service_type    = "redis"
  volume_name     = "cache-data"
  prefix          = "volumes/cache/"
  cron_expression = "30 4 * * *"
  destination_id  = dokploy_destination.backups.id
}

Schema

Required

  • cron_expression (String) Standard five-field cron expression, for example 0 4 * * *.
  • destination_id (String) Id of the dokploy_destination that receives the archives.
  • name (String) Display name.
  • prefix (String) Key prefix inside the destination bucket, for example volumes/web/.
  • service_id (String) Id of the service that owns the volume. A change forces a replacement: the Dokploy update endpoint sets the new parent without a clear of the old one, and the record then belongs to two services at once.
  • service_type (String) Kind of service that service_id refers to: one of application, postgres, mysql, mariadb, mongo, redis, compose, libsql. A change forces a replacement, for the same reason as service_id.
  • volume_name (String) Name of the Docker volume to archive.

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, and a backup in the configuration that never runs is the worse failure.
  • keep_latest_count (Number) Number of archives to keep. Omit it to keep all of them.
  • service_name (String) Name of the specific container, for compose services with more than one.
  • turn_off (Boolean) The Dokploy turnOff flag, passed through unchanged. The server coerces an absent key and an explicit null to false, so this attribute always sends a value.

Read-Only

  • app_name (String) Internal Dokploy app name. The server generates it.
  • created_at (String) Creation timestamp from the server.
  • id (String) Volume backup id.

Import

Import is supported using the following syntax:

In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:

terraform
import {
  to = dokploy_volume_backup.uploads
  id = "v1a2b3c4d5e6f7g8h9i0j"
}

The terraform import command can be used, for example:

shell
terraform import dokploy_volume_backup.uploads v1a2b3c4d5e6f7g8h9i0j