This scenario walks through the full database backup lifecycle:
- Provision a PostgreSQL database
- Configure automated daily backups with local retention
- Trigger an immediate backup on creation
- Monitor backup status via the executions data source
A coolify_database_backup resource is a schedule (cron frequency,
retention policy, S3 destination). It does not have a "status" field
because the schedule itself is always either enabled or disabled.
The actual results of each backup run are executions. Use the
coolify_backup_executions data source to list them:
data "coolify_backup_executions" "latest" {
database_uuid = coolify_database_postgresql.app_db.uuid
backup_uuid = coolify_database_backup.daily.uuid
}
# Check the most recent execution
output "latest_status" {
value = data.coolify_backup_executions.latest.executions[0].status
}Each execution has:
uuid- unique identifierstatus-"success","failed", or"running"created_at- when the backup startedsize- backup file size in bytes
To store backups in S3 (in addition to local), first create the S3 storage in
the Coolify web UI, then enable save_s3 and point the backup at that UUID:
resource "coolify_database_backup" "daily" {
database_uuid = coolify_database_postgresql.app_db.uuid
frequency = "0 2 * * *"
enabled = true
save_s3 = true
s3_storage_uuid = "existing-ui-managed-s3-storage-uuid"
retain_amount_locally = 7
retain_amount_s3 = 30
}Top-level S3 storage is managed in the Coolify web UI. This scenario expects an existing storage UUID.
export TF_VAR_coolify_endpoint="http://localhost:8000"
export TF_VAR_coolify_token="your-token"
export TF_VAR_server_uuid="your-server-uuid"
terraform init
terraform apply
# After apply, check backup status:
terraform output latest_execution_statusterraform test -verbose