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
# Nightly archive of the uploads volume of an application. Dokploy accepts
# only a volume that the service mounts, so the backup references the mount.
resource "dokploy_mount" "uploads" {
service_id = dokploy_application.web.id
service_type = "application"
type = "volume"
volume_name = "web-uploads"
mount_path = "/app/uploads"
}
resource "dokploy_volume_backup" "uploads" {
name = "web-uploads-nightly"
service_id = dokploy_application.web.id
service_type = "application"
volume_name = dokploy_mount.uploads.volume_name
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. Dokploy
# creates the data volume <app_name>-data with each database.
resource "dokploy_volume_backup" "cache" {
name = "cache-nightly"
service_id = dokploy_redis.cache.id
service_type = "redis"
volume_name = "${dokploy_redis.cache.app_name}-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 example0 4 * * *.destination_id(String) Id of thedokploy_destinationthat receives the archives.name(String) Display name.prefix(String) Key prefix inside the destination bucket, for examplevolumes/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 thatservice_idrefers to: one ofapplication,postgres,mysql,mariadb,mongo,redis,compose,libsql. A change forces a replacement, for the same reason asservice_id.volume_name(String) Name of the Docker volume to archive. Since Dokploy v0.31.1 the volume must belong to the service: adokploy_mountof typevolumeon the service, or for a compose service a volume whose name starts with<app_name>_or that the container named byservice_namemounts. Referencedokploy_mount.<name>.volume_nameso that Terraform creates the mount first.
Optional
enabled(Boolean) Whether the backup runs. Defaults totrue. 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 DokployturnOffflag, passed through unchanged. The server coerces an absent key and an explicit null tofalse, 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:
import {
to = dokploy_volume_backup.uploads
id = "v1a2b3c4d5e6f7g8h9i0j"
}The terraform import command can be used, for example:
terraform import dokploy_volume_backup.uploads v1a2b3c4d5e6f7g8h9i0j