wihan/dev

docs /dokploy / resources

markdown
browse the dokploy docs

dokploy_backup (Resource)

A scheduled logical dump of a database to an S3-compatible destination.

~> Redis is not supported here. Dokploy has no logical dump for Redis; use dokploy_volume_backup, which snapshots the volume instead and does accept a Redis parent.

~> Backing up the Dokploy instance itself (Dokploy’s web-server backup type) is not exposed by this resource: it has no parent service and needs a separate validation path.

Example Usage

resource "dokploy_backup" "db_nightly" {
  service_id     = dokploy_postgres.db.id
  service_type   = "postgres"
  database       = "vanillauys"
  prefix         = "backups/vanillauys/"
  schedule       = "0 3 * * *"
  destination_id = dokploy_destination.backups.id

  keep_latest_count = 30
}

# Redis has no logical dump in Dokploy. This resource rejects it at plan
# time; use dokploy_volume_backup instead.

Schema

Required

  • database (String) Name of the database to dump.
  • destination_id (String) Id of the dokploy_destination dumps are written to.
  • prefix (String) Key prefix inside the destination bucket, e.g. backups/vanillauys/.
  • schedule (String) Standard five-field cron expression, e.g. 0 3 * * *.
  • service_id (String) Id of the database or compose service to dump. Changing it forces replacement: Dokploy’s update endpoint carries no parent field at all, so a retarget is not expressible.
  • service_type (String) Kind of service service_id refers to: one of postgres, mysql, mariadb, mongo, libsql, compose. Changing it forces replacement. Dokploy’s own databaseType and backupType fields are derived from this — setting them independently is what allows a record whose type and parent disagree, so they are not exposed.

Optional

  • enabled (Boolean) Whether the backup runs. Defaults to true: Dokploy leaves this null when a record is created through the API alone, which is neither on nor off, and a backup declared in configuration that silently never runs is the worse failure.
  • include_encryption_key (Boolean) Include the database encryption key in the dump. Defaults to true, matching what Dokploy stores for a newly created backup. This provider always transmits the field: Dokploy’s update endpoint stores false when it is omitted, so a request that left it out would silently turn it off on a record created with it on.
  • keep_latest_count (Number) How many dumps to retain. Omit to keep all of them.
  • service_name (String) Name of the specific container, for compose services with more than one.

Read-Only

  • app_name (String) Dokploy-internal app name, generated by the server.
  • id (String) Backup id.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

terraform import dokploy_backup.db_nightly b1a2b3c4d5e6f7g8h9i0j