{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/skycloak-io/json-schema/skycloak-io-backup-schema.json",
  "title": "Backup",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/skycloak-io-openapi.yaml#/components/schemas/Backup",
  "type": "object",
  "required": [
    "id",
    "cluster_id",
    "type",
    "status",
    "retention_days",
    "size_bytes",
    "copy_status",
    "created_at"
  ],
  "properties": {
    "id": {
      "$ref": "#/$defs/BackupId"
    },
    "cluster_id": {
      "$ref": "#/$defs/ClusterId"
    },
    "type": {
      "$ref": "#/$defs/BackupType"
    },
    "status": {
      "$ref": "#/$defs/BackupStatus"
    },
    "retention_days": {
      "type": "integer",
      "format": "int32",
      "description": "Days the backup is kept after it completes."
    },
    "size_bytes": {
      "type": "integer",
      "format": "int64",
      "description": "Size of the stored backup in bytes. Set once `status` is `completed`."
    },
    "sha256": {
      "type": "string",
      "x-oapi-codegen-extra-tags": {
        "validate": "omitnil,max=500"
      },
      "description": "SHA-256 of the stored (encrypted) object, hex. Set once `status` is `completed`."
    },
    "keycloak_version": {
      "type": "string",
      "x-oapi-codegen-extra-tags": {
        "validate": "omitnil,max=500"
      },
      "description": "Keycloak version whose database was backed up."
    },
    "failure_reason": {
      "type": "string",
      "x-oapi-codegen-extra-tags": {
        "validate": "omitnil,max=500"
      },
      "description": "Machine-readable failure cause when `status` is `failed`: `JobFailed`, `JobLost`, `Missed`, `BackupsDisabled`, `InvalidReport`, `DatabaseNotReady` or `StorageNotConfigured`."
    },
    "copy_status": {
      "allOf": [
        {
          "$ref": "#/$defs/BackupCopyStatus"
        }
      ],
      "description": "State of the off-site copy to your own bucket. A failed copy never changes `status`, retention or the download link."
    },
    "copy_failure_reason": {
      "type": "string",
      "x-oapi-codegen-extra-tags": {
        "validate": "omitnil,max=500"
      },
      "description": "Short failure code when `copy_status` is `failed`."
    },
    "copied_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the copy to your bucket finished, for `copy_status` `copied`."
    },
    "requested_at": {
      "type": "string",
      "format": "date-time"
    },
    "started_at": {
      "type": "string",
      "format": "date-time"
    },
    "completed_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the backup is deleted from storage."
    },
    "deleted_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the backup was deleted from storage, for `status` `deleted`."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "BackupCopyStatus": {
      "type": "string",
      "enum": [
        "not_configured",
        "pending",
        "copied",
        "failed"
      ]
    },
    "BackupId": {
      "type": "string",
      "pattern": "^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$",
      "description": "Backup identifier: `auto-<yyyymmddhhmm>` for an automatic backup, `manual-<timestamp>-<suffix>` for an on-demand one."
    },
    "BackupStatus": {
      "type": "string",
      "enum": [
        "pending",
        "running",
        "completed",
        "failed",
        "deleted"
      ]
    },
    "BackupType": {
      "type": "string",
      "enum": [
        "automatic",
        "manual"
      ]
    },
    "ClusterId": {
      "type": "string",
      "format": "uuid"
    }
  }
}