Introducing a new way to review your PRs.

Read the announcement

replicatedhq / kots

KOTS provides the framework, tools and integrations that enable the delivery and management of 3rd-party Kubernetes applications, a.k.a. Kubernetes Off-The-Shelf (KOTS) Software.

View on GitHub

21 documents · Updated Nov 23, 2026

docs / snapshot-and-disaster-recovery

Snapshots and disaster recovery

Snapshots preserve the Admin Console state, application state, and persistent volume data so an installation can be recovered after loss or moved to a new cluster. The snapshot system uses Velero as its backup and restore engine, while KOTS selects the data scope, stores the backup location, schedules work, and coordinates the order in which the Admin Console and applications return. This page is a child of Backup, recovery, and support operations and relates to Support bundle collection.

Snapshot model

Backup scopes

The system supports two related backup scopes. An application backup protects one deployed application and its declared data. An instance backup protects the installation and its applications as a recovery unit.

Application backups use the deployed application version as their source. The backup includes the Admin Console namespace, the target application namespace, application-declared namespaces, matching application resources, cluster resources, and persistent volumes selected by the rendered backup policy. Shutdown pods are left out because they do not represent live application state.

Instance backups collect the state needed to rebuild an installation. They include the Admin Console and application namespaces plus platform namespaces when the installation uses an embedded cluster. The backup records the application versions, deployed sequences, installation image, storage details, and cluster facts as metadata so a later restore can rebuild the same operating context.

The system presents Velero backup objects through a KOTS backup view. This view joins the infrastructure and application parts of a modern instance backup and reports one status, time range, retention point, included applications, and volume summary. Legacy instance backups remain a single combined object.

References: pkg/…/backup.go• L50-201 pkg/…/backup.go• L226-285 pkg/…/backup.go• L428-511 pkg/…/backup.go• L516-581 pkg/…/backup.go• L813-923 pkg/…/types.go• L15-54

Backup lifecycle

The backup lifecycle starts with a manual request or a schedule. KOTS builds the scope from the current deployed state and the application backup policy. Velero then copies Kubernetes resources and persistent volume data to the configured backup storage location.

The lifecycle is asynchronous. A request returns the backup name while Velero records progress. KOTS reads Velero phases and volume records to show progress and to distinguish a completed backup from a failed or partly failed backup. Finished backups can also expose hook output, errors, warnings, and volume detail.

The flow below shows how a request becomes stored backup data and then a user-facing result.

flowchart LR
    A[Manual or scheduled request] --> B[Build backup scope]
    B --> C[Create Velero Backup]
    C --> D[Copy cluster resources and volumes]
    D --> E[Store backup data]
    E --> F[Read Velero status and volume progress]
    F --> G[KOTS backup status and details]

References: pkg/…/backup.go• L708-810 pkg/…/backup.go• L978-1012 pkg/…/backup.go• L32-109 pkg/…/backup.go• L117-180

Snapshot storage

Backup storage location

The backup storage location is the Velero resource that connects a cluster to the place where backup metadata and volume data are kept. KOTS finds the default location in the detected Velero namespace, reads its provider settings, and updates it when an operator changes snapshot storage.

Storage settings have one active provider at a time. The supported choices cover cloud object stores, internal object storage, a legacy Minio-backed filesystem, and the local-volume-provider filesystem path. KOTS validates the selected location before it writes the setting and keeps access data in Kubernetes secrets used by Velero and its node agent. For S3-compatible endpoints that use a private or self-signed HTTPS certificate, an operator can provide a CA certificate so KOTS can validate the endpoint without removing trust in normal system certificates.

The storage choice affects disaster recovery. A location that exists only on the source cluster cannot protect against loss of that cluster. An external object store gives the replacement cluster a durable source. An internal store or filesystem path gives a recovery path only when its data remains available to the replacement environment.

References: pkg/…/store.go• L51-83 pkg/…/store.go• L101-169 pkg/…/store.go• L420-588 pkg/…/store.go• L865-1011 pkg/…/store.go• L1376-1476 pkg/…/snapshots.go• L37-72

Object-store providers

Cloud and S3-compatible providers use Velero's object storage interface. The system supports AWS S3, Google Cloud Storage, Azure Blob Storage, and other S3-compatible endpoints. Each provider may use credentials or a platform identity, and the selected credentials are checked before the backup storage location is made active.

Embedded-cluster installations can use the internal object store supplied by the cluster. This path is limited to supported cluster types and uses the cluster's own storage settings. The configuration process also makes sure Velero and its node agent can read the needed credentials and pull their images when a private registry is in use.

References: pkg/…/store.go• L172-417 pkg/…/store.go• L471-588 pkg/…/store.go• L1177-1237 pkg/…/store.go• L1240-1474 cmd/…/velero.go• L97-170 cmd/…/velero.go• L173-724

Filesystem providers

Filesystem snapshots use either a host path or an NFS export. The system has two provider modes. The legacy mode runs a small Minio object store over the mounted filesystem. The newer mode uses Velero's local-volume-provider and writes its repository data directly through the filesystem plugin.

KOTS checks that the filesystem can mount and accept writes before it uses the location. It preserves enough information to detect old Minio data and to support migration. A path that belongs to another Minio instance can require an explicit reset because reusing it changes which Minio instance can read that data.

Velero version matters for this choice. Local-volume-provider filesystem snapshots are not supported on Velero 1.17 and later. Newer installations must use an object-store backend or a Velero version that still supports the filesystem provider.

References: pkg/…/filesystem.go• L10-30 pkg/…/filesystem_minio.go• L40-129 pkg/…/filesystem_minio.go• L933-972 pkg/…/filesystem_lvp.go• L21-45 pkg/…/filesystem_lvp.go• L158-237 pkg/…/velero_flags.go• L7-58 pkg/…/snapshots.go• L188-225

Velero access

Velero access is part of storage setup rather than a separate operator task. On installations with cluster-wide access KOTS can discover Velero directly. On minimal-RBAC installations, KOTS needs a role and role binding in the Velero namespace plus a ConfigMap that records that namespace.

The Admin Console checks this access before it exposes storage and schedule actions. If access is missing, the API returns a conflict that tells the operator to grant the required Velero namespace access. This prevents a valid storage setting from appearing usable when KOTS cannot read or create the Velero resources behind it.

References: pkg/…/velero.go• L57-181 pkg/…/velero.go• L184-265 pkg/…/snapshots.go• L908-929 cmd/…/velero.go• L52-95

Snapshot scheduling

Application schedules

Application schedules create one future snapshot for each application with automatic snapshots enabled. The schedule is a standard cron expression stored with the application. A background loop checks due entries about once per minute.

When an entry is due, the scheduler first avoids overlap with an unfinished application backup. It then creates a scheduled Velero backup, links the resulting backup name to the queue entry, removes extra pending entries if needed, and queues the next time from the cron expression. Disabling or changing a schedule clears old pending entries before it creates the new first entry.

References: pkg/…/snapshotscheduler.go• L39-150 pkg/…/snapshots.go• L498-699 pkg/…/snapshot_store.go• L15-99 migrations/…/scheduled_snapshots.yaml• L1-26

Instance schedules

Instance schedules follow the same queue pattern for a cluster. They create a full instance backup rather than an application-only backup. The scheduler delays a due instance backup while another instance backup is still running.

The schedule and retention settings belong to the cluster record. This keeps the recovery policy separate from each application's policy while allowing the same backup engine and status model to report both kinds of work.

References: pkg/…/snapshotscheduler.go• L56-68 pkg/…/snapshotscheduler.go• L153-264 pkg/…/snapshots.go• L701-906 pkg/…/snapshot_store.go• L101-184 migrations/…/scheduled_instance_snapshots.yaml• L1-26

Retention

Retention is stored as a duration on the application or cluster and passed to Velero as the backup time-to-live. The user-facing setting accepts seconds, minutes, hours, days, weeks, months, and years. KOTS converts these values to the duration form used by Velero and shows the same value when it reads the setting back.

Retention controls when Velero expires stored backup data. It does not make a new backup and does not replace the need for a storage location that survives cluster loss.

References: pkg/…/ttl.go• L13-93 pkg/…/backup.go• L181-189 pkg/…/backup.go• L323-329 pkg/…/backup.go• L503-507 pkg/…/snapshots.go• L507-523 pkg/…/snapshots.go• L721-737

Disaster recovery

Legacy instance restore

Legacy instance restore rebuilds the Admin Console first and applications second. The restore must refer to a completed legacy instance backup with the recorded Admin Console image and deployment namespace. KOTS checks these backup facts before it changes the cluster. It then removes the existing Admin Console objects, creates a Velero restore for the Admin Console resources and volumes, waits for the Admin Console to return, and asks the restored Admin Console to restore applications.

Application restoration can run for all applications or for a selected set. KOTS tracks one application restore at a time in the application state and exposes Velero restore phases, volume progress, errors, and warnings. The caller can wait for all applications or return after the application restore has started.

The recovery sequence below shows the boundary between cluster-level restoration and application-level restoration.

sequenceDiagram
    participant O as Operator
    participant K as KOTS recovery flow
    participant V as Velero
    participant A as Restored Admin Console

    O->>K: Select completed instance backup
    K->>V: Restore Admin Console resources and volumes
    V-->>K: Restore phase and volume progress
    K->>A: Wait for Admin Console to start
    K->>A: Start application restore
    A->>V: Create application restore objects
    V-->>A: Application restore phases
    A-->>K: Application restore status
    K-->>O: Complete or in-progress result

The command surface allows the operator to restore only the Admin Console or only applications. It rejects a request that excludes both parts. The web flow adds checks that the selected snapshot belongs to the application and that the captured application version was deployed to the cluster before it starts an application restore.

References: pkg/…/restore.go• L28-264 pkg/…/restore.go• L266-304 pkg/…/restore_test.go• L11-102 pkg/…/restore.go• L33-125 pkg/…/restore.go• L137-216 pkg/…/restore.go• L232-336 cmd/…/restore.go• L21-89

Embedded-cluster recovery

Embedded-cluster disaster recovery can produce separate infrastructure and application backup objects. The application backup carries the vendor-defined restore policy when both backup and restore policies are available. The infrastructure backup carries the cluster and Admin Console state.

KOTS groups these objects by a shared backup name. A grouped backup is complete only when all expected Velero backup objects exist and their phases roll up to a successful result. During recovery, the stored restore policy tells the application side how to restore its own data. This split lets the cluster layer rebuild platform state before the application layer restores application-specific state.

References: pkg/…/backup.go• L397-425 pkg/…/backup.go• L428-511 pkg/…/backup.go• L514-581 pkg/…/backup.go• L847-923 pkg/…/backup.go• L288-300

Restore status

Restore status comes from Velero restore objects and their persistent-volume restore records. For finished restores, KOTS also reads Velero results so operators can see errors and warnings. On OpenShift, known duplicate-resource warnings can be filtered when the warning refers to a resource created during the restore itself.

The application state records the active restore name. That state prevents overlapping application restores and supports cancellation by clearing the active marker. A missing restore object is shown as a new restore unless the application undeploy step recorded a failure, in which case the API reports a failed restore with a request to inspect logs.

References: pkg/…/restore.go• L174-243 pkg/…/restore.go• L246-285 pkg/…/openshift.go• L57-125 pkg/…/restore.go• L318-416 pkg/…/app.go• L21-26

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to backup type labels, expected backup counts, or shared backup names must stay aligned with grouping, status rollup, deletion, and restore lookup.
  • Changes to included namespaces or cluster-resource selection must be checked against both legacy instance restore and embedded-cluster infrastructure recovery.
  • Changes to the backup storage location provider must update provider detection, credential secret handling, filesystem configuration reads, and Velero version checks together.
  • Changes to storage endpoint trust settings must preserve CA data in the Velero storage location and use it during endpoint validation without removing normal system certificate trust.
  • Changes to schedule persistence must preserve the pending-entry rule: one future unclaimed entry per application or cluster.
  • Changes to restore annotations or embedded-cluster restore policy must remain readable from the backup after the source Admin Console is gone.
  • Changes to minimal-RBAC setup must keep the Velero namespace record, role, role binding, and API access check consistent.
  • Changes to legacy restore validation must keep the backup type, completion phase, Admin Console image, and deployment namespace checks aligned with restore creation.

Important failure modes

TriggerConsequenceGuard
No default Velero backup storage locationBackup, restore, list, or detail operations cannot find their data sourceConfigure and validate one active default location before use
KOTS lacks access to the Velero namespaceAdmin Console storage and snapshot actions return an access conflictGrant the KOTS role and role binding and record the Velero namespace
Filesystem path is not writable or no longer matches its prior Minio dataFilesystem provider setup fails or risks hiding prior snapshot dataValidate the mount and require an explicit reset when the path belongs to another Minio instance
Local-volume-provider is selected with Velero 1.17 or laterFilesystem snapshots cannot run with the selected providerUse an object-store backend or a supported older Velero release
CA data is malformed or does not sign the storage endpointStorage validation fails before the location becomes activeProvide valid CA certificate data for the endpoint or use a certificate trusted by the system
A storage endpoint does not return response headers during validationValidation waits only for its bounded response period and then failsRestore endpoint reachability before activating the location
Scheduled backup is due while another backup is unfinishedThe new snapshot is postponedThe scheduler checks unfinished application or instance backups before creation
Restore starts from a failed, partial, or in-progress backupRecovery is rejected before resources are changedRestore accepts only a completed legacy instance backup
Instance backup lacks its recorded Admin Console image or deployment namespaceRestore is rejected before the Admin Console is removedKeep both recovery annotations in the backup metadata
A modern embedded-cluster backup is treated as a legacy backupThe restore path cannot use its separate application and infrastructure policyCheck backup type and restore only supported legacy instance backups through this flow
One part of a grouped instance backup is missingThe KOTS backup is marked failed even if another part completedCompare the actual Velero object count with the expected count

Key files

FileWhy to read it
pkg/…/backup.goMain backup orchestration, backup scope, grouping, metadata, status, and volume summaries
pkg/…/store.goStorage provider model, backup storage location, credentials, endpoint validation, and provider discovery
pkg/…/filesystem_minio.goLegacy filesystem-backed object storage and path safety checks
pkg/…/filesystem_lvp.goLocal-volume-provider setup for host paths and NFS exports
pkg/…/restore.goLegacy instance restore order, eligibility checks, and command-level restore waiting
pkg/…/restore_test.goRestore eligibility checks for backup type, completion, and recovery metadata
pkg/…/restore.goRestore object creation, restore detail, volume progress, and restore results
pkg/…/snapshotscheduler.goApplication and instance schedule loops and queue repair behavior
pkg/…/snapshots.goAPI-facing storage, schedule, retention, and Velero status workflows
pkg/…/restore.goApplication restore checks, status, selection, and cancellation
pkg/…/snapshot_store.goPersistent queues for scheduled application and instance snapshots
pkg/…/types.goBackup identity, type, trigger, grouping, and status contracts
cmd/…/velero.goOperator-facing storage provider and Velero permission workflows
cmd/…/restore.goOperator-facing disaster recovery options