External backup and disaster recovery

Documentation home

Replication preserves ordered acknowledged writes while the configured majority and durable authority survive. It is not a backup. A quorum-lost group cannot identify the latest committed state by selecting the largest file, newest mtime, Running Pod, surviving checkpoint or apparent longest journal. Restoring a stale backup deliberately loses changes since that backup. Record its time, digest, source identity, application consistency point and the accepted loss before application cutover.

The supported recovery direction is application files from a verified external backup into a new PVC/volume/generation, using the ordinary local-backed CSI path. Never reset a journal, copy another generation's backing tree into a worker, change Node identity, reduce voting membership, or edit finalizers/allocation metadata to make uncertain state serve. Old journal/checkpoint authority is not imported by the external tools.

Self-service restore from a scheduled backup

Use this workflow on a cluster with the backup runner installed and scheduled restore enabled. On installations using the standalone tools, follow Backup contract.

You can do every tenant step from your workstation. Submit the request in your application's GitLab repository and follow progress in your Kubernetes namespace. A restore worker uses ordinary PVC mounts. You need permission to change the application's manifests, read the restore result in your namespace and select archives from an approved backup destination.

Choose a recovery point

In the backup catalog, find your original claim by namespace and name. To choose a specific recovery point, find a verified archive by its capture date and time. Review that timestamp with anyone who needs changes made after it, and copy the exact archive name shown in the catalog. If your site has separate private and published claims, select the archive for each claim and check both timestamps before starting.

Your namespace has a ConfigMap for each backup destination available to it. The archives.json entry lists archive names, source claims and capture times. From your workstation, you can find the catalog and open it in your Kubernetes dashboard or with kubectl describe configmap.

kubectl -n websites-example get configmaps -l replicated.csi.tak-os.org/backup-catalog

Choose a fresh, empty PVC in the namespace where your application will use it. The driver reads the restore request when it provisions that claim. Adding a restore annotation to a previously provisioned PVC leaves its files in place. For a running application, use a new claim name and keep the existing claim available while you check the restored copy. In an empty replacement cluster, you can use the original claim names. Keep workflows that mount the destination PVC paused until its restore is verified.

Submit the restore in GitLab

On the new PVC, include your normal backup configuration and add csi.replicated.tak-os.org/restore-from with the archive name or a quoted empty string. The backup configuration supplies the destination PVC and folder where the catalog lives.

csi.replicated.tak-os.org/restore-from: ""

The empty string requests the most recently captured backup for the same PVC name and namespace in that catalog. Once the driver selects an archive, it uses that recovery point for all retries. If you give the replacement PVC a new name, specify the archive name explicitly. Omit the annotation for ordinary PVC provisioning.

This example restores backup-12345.takbak into site-data-restore and sets up future nightly backups in the production folder of backups/site-archives. Use the StorageClass and access mode for your application. Give the restore PVC enough storage for the files after they are unpacked.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: site-data-restore
  namespace: websites-example
  annotations:
    csi.replicated.tak-os.org/backup: |
      {
        "version": 1,
        "destination": {
          "namespace": "backups",
          "pvc": "site-archives",
          "folder": "production"
        },
        "schedule": "15 2 * * *",
        "timeZone": "Etc/UTC",
        "retention": { "daily": 7, "weekly": 4, "monthly": 12 }
      }
    csi.replicated.tak-os.org/restore-from: "backup-12345.takbak"
spec:
  storageClassName: tak-os-replicated-rwx
  accessModes: [ReadWriteMany]
  resources:
    requests:
      storage: 10Gi

Commit the PVC manifest and let Orbit apply it. The restore checks that the target is empty, validates the selected archive, then restores the files, ownership, permissions and links. The driver reads back the restored tree and records the verified result against the destination claim and archive. It then removes restore-from from the live PVC.

Verify the result and check your app

Look for Verified for the expected archive in the PVC's csi.replicated.tak-os.org/restore-status annotation. Bound means Kubernetes allocated the volume. Application Pods can mount it only after the restore and read-back finish. If the backup is missing or Kubernetes cannot mount the backup PVC, application mounts stay blocked. The restore retries automatically when the backup becomes available. Keep the PVC and its request in place while the archive or backup storage is brought back. The recorded result remains visible after the driver clears the request. If you use kubectl, you can inspect the PVC details and events from your workstation.

kubectl -n websites-example describe pvc site-data-restore

Once every claim your application needs is verified, update its workload in GitLab to use the restored claims and enable it. Check the application itself. For a site, open the public home page and check that the CMS can read the expected content. Future scheduled backups of the restored claim can start after verification.

If the restore fails, keep the workload paused and review the reported reason. Give support the namespace, destination claim name, archive name and error. If an attempt left files on the destination, preserve that claim for investigation and use a fresh empty one for the next request.

Clear the request from Git after confirming it works

Orbit creates a missing object from its Git manifest. For an existing object, Orbit applies an update when that object's YAML in Git changes. Orbit leaves live-only changes in place while the Git YAML stays the same. This lets the driver's removal of restore-from stay in effect while the request is still in Git and you confirm the application works.

After confirming the application works, open the PVC manifest in GitLab, remove the csi.replicated.tak-os.org/restore-from line, and commit the edit. Keep csi.replicated.tak-os.org/backup to continue scheduled backups. If another edit to this PVC's YAML causes Orbit to put the same request back on the existing claim first, the driver recognizes its recorded completion and clears the annotation again. A recreated PVC is a new claim and will take any restore-from still in its manifest as a new request.

Restore after a cluster rebuild

Once the backup storage is available as a PVC in the replacement cluster, use its catalog to find your archives and follow the same steps. You can recover the original claim names into fresh PVCs, then bring the application up from GitLab and let ESO supply its Secrets from Bitwarden. The archives supply the application files and their filesystem metadata.

Configure scheduled backups for a cluster

Install one backup runner per destination PVC using the Orbit integration fragment. Supply the backup image from the same build as the manager, node and replica images. Create the destination namespace and an independent filesystem PVC before applying the fragment. Give the runner exclusive write access to its backup directory. Set the claim name, relative folder and allowed source namespaces in the runner's arguments. Include the tenant Role and RoleBinding in each allowed namespace. The runner is a trusted driver component. Its service account reads volume credentials and manages restore helper Pods only in configured source namespaces. The helper needs permission to set ownership on the restored claim. Grant the node service account read access to the restore records and complete the node image rollout before enabling --enable-scheduled-restore on managers.

Tenants opt in by setting the backup annotation on their source claims. The runner selects the latest due slot within the last 24 hours and publishes one full, verified archive for that slot. Daily, ISO-weekly and monthly retention keep the most recent verified archive in each retained period. One archive can fill several slots. Periods follow the configured timezone. Expiration runs after a new archive has been verified and catalogued. Removing a policy or deleting its claim preserves that claim's existing archives. A fresh claim, even with the same name, starts its own retention history.

The runner mounts the destination as ordinary filesystem storage. The replica exports the logical file tree at a committed index, including file modes, owners, timestamps and link relationships. Capture has a three-second budget checked between storage operations and an 8 GiB logical-data limit. Captures can delay writes while the replica copies data under its lock. A capture that exceeds its limits, loses quorum or fails verification leaves earlier backups available. A recovery point covers one PVC. Coordinate application writers before capture if several PVCs need to represent the same application state.

The archive and its catalog record live together on the destination PVC. The runner rebuilds namespace catalogs from those records. During a restore, a short-lived helper mounts the new claim, receives the selected archive through the Kubernetes streaming API and verifies the restored data. The CSI mount gate holds application mounts until the restore is verified and the helper is removed. Restore and backup operations report status through the PVC, catalog, structured logs and bounded metrics.

Required metadata-loss recovery

On 2026-11-23 the operator required immediate automatic recovery when volume metadata or credentials disappear, including when application files have no external backup. The CRD-free build detects missing records from surviving application and backing PVs and persists binding identities on disk. Automatic record reconstruction and transport credential recovery remain outstanding. Operators can recover files from an external backup or from offline replica copies using the procedures below.

The driver does not encrypt file contents, journals or checkpoints at rest. Certificates and tokens authenticate network traffic; they are not needed to decrypt surviving data. Lost credentials must trigger credential recovery or isolated file salvage rather than a conclusion that the files are unrecoverable. Automatic trust replacement must coordinate the recovered workers and isolate obsolete writers so recovery does not create conflicting writes or destroy a better surviving copy. Driver-managed data-at-rest encryption is prohibited by the operator's decision. Host/provider encryption is independent configuration.

In pre-incident releases, backing PVCs carried replicated.csi.tak-os.org/volume and a ReplicatedVolume owner reference. Workers already fsync identity.json containing volume, logical generation, member ID and peer membership; local CSI persists allocation records containing the local handle, node and backing claim metadata. The earlier identity file omitted the original application claim and full local binding. The CRD-free build adds recovery.json to each worker root and uses ownerless backing claims with retained local PVs. An application PV carries a versioned binding annotation. These are independent recovery evidence.

The required responsibilities are:

  • The manager compares surviving application PVs and node recovery inventories against lifecycle and backing objects, independently of lifecycle record inventory success. On first successful detection it begins a persistent recovery operation before ordinary lifecycle work. It records progress or the exact unavailable evidence through Events, structured logs and bounded-label metrics; it must not report an empty inventory as healthy while referenced volumes are missing.
  • Backing PVC/PV metadata and a durable, versioned filesystem record identify the original application namespace/name/UID, volume and logical generation, replica/member and membership-transition history, original Node UID, local-CSI handle and PVC/PV bindings, and lifecycle/deletion state. The record is written atomically and fsynced at lifecycle transitions, outside ordinary file I/O. A node inventory must remain discoverable when lifecycle records and Secrets are missing. API-only copies do not satisfy that requirement.
  • The node runtime inspects existing local-CSI allocations through an explicit backing-driver inventory/recovery contract. Local CSI retains allocation and physical reclamation responsibility; replicated CSI must not become another provisioner or discover/format raw disks. Missing API ownership must not reclaim live original data. Normal explicit deletion still needs its durable fence, retained cleanup intent, and crash-safe local-CSI reclamation.
  • Recovery rebuilds missing objects from preserved original bindings and replica state, keeping logical generation independent of a recreated ConfigMap's UID. It restores usable transport credentials or initiates isolated salvage when the original credentials are gone. It resumes normal writes only when the original committed state and writer isolation are established. It preserves ambiguous copies, reports any uncertain recovery point, and never creates an empty replacement over original storage, resets journals, silently reduces quorum, or chooses a winner from mtimes/Pod readiness.

Remaining work is tracked as REC-01 through REC-03 in TODO. In the TLSPU incident, the approved live surveys on k01, k02 and k03 found only five unrelated local allocations. The operator later restored the nodes in isolation from the provider snapshot reported at 16:51 UTC on 22 November and saved the restored storage outside Kubernetes. The offline export verified 21 file archives covering all 19 affected PVCs. Keep the replica copies and archives independently of the cluster during driver removal and data restoration.

Copy readable files from a recovered replica

The 4.0.1 worker stores an ordinary filesystem tree in /var/lib/tak-os/local-volumes/<local-handle>/materialized-*/files/. Use a preserved offline copy of the node. Keep the complete replica directory and local CSI's .metadata separately, including identity.json, raft.db, snapshots/ and all materialized trees. Starting a worker can reconstruct the tree and remove older materializations.

Use tools/salvage-replica-files.py with Python 3.11+ and GNU tar against each node copy. Give it the incident JSON report containing survivingVolumes. The script matches both Volume and Generation in replica identity.json to the original application PVC. Run the command below from the source checkout and choose a new output directory on separate storage whose parent already exists. Omit --output to list candidates and claims absent from that node copy.

python3 tools/salvage-replica-files.py \
  --report /mnt/backup/incident-volume-inventory.json \
  --root /mnt/restored-k01/var/lib/tak-os/local-volumes \
  --output /mnt/backup/k01-site-files

The output includes one ordinary .tar and SHA-256 checksum per candidate tree under the claim namespace/name. The script compares each tar to its source tree before publishing it. Use separate output directories for each node so multiple copies remain available. Keep private and published archives separate. An empty candidate is flagged in the JSON output. A missing tree means this file export has nothing to copy for that replica. Preserve its journal and checkpoints for further recovery. Keep all candidates if there are several; filesystem timestamps do not establish which tree contains the committed state.

A direct export captures visible paths and file bytes as they exist on the copied disk. The driver tracks application UID/GID, permissions, timestamps and symlink targets separately. Symlink placeholders appear as regular files in the export. Review the application's files and restore its permissions and links before serving them from a new filesystem. If the original CSI mount becomes available and can be quiesced, take a mounted backup to capture the logical filesystem metadata as well.

Backup contract

tools/backup-volume.py and tools/restore-volume.py are standalone Python 3.11+ operator tools, not a snapshot API or a new backup controller. Run them against a mounted application filesystem. They do not call Kubernetes or inspect worker backing paths. For standalone use, schedule and retain their archives through your platform. For managed scheduling and retention, use the backup runner described above. Independent storage, access control and any archive encryption are platform responsibilities.

Stop application writers, close descriptors and complete their acknowledged writes first. An application database needs its own consistent logical export; file-backed databases/locks/mmap remain unsupported on this filesystem. A walk of a live tree is not a transaction snapshot. Unlinked open files, dedup state, leases, inode/object IDs, ctime, credentials and replication history are not backed up. A new volume has new object identities. Quorum must be healthy to create a fresh backup; loss of quorum requires a previously completed backup.

The version-1 TAKBAK1 format stores a bounded checksummed JSON manifest and checksummed regular-file extents. It preserves relative UTF-8 paths, file bytes, directories, UID/GID/basic mode, nanosecond atime/mtime, regular-file hardlink relationships and opaque symlink targets. Zero 1MiB chunks need no payload; restore writes offset extents and truncates to the original logical size. Exact physical block allocation is not promised. Symbolic links are never traversed for writes. ACLs, xattrs, special mode bits and special files are refused rather than silently omitted. Metadata restoration requires appropriate ownership and permission privileges; archive/restore processes need the appropriate access to the mounted filesystem, not raw disks or Kubernetes credentials.

Limits default to 100,000 entries, 64MiB manifest, 65,536 extents per file, 1TiB logical file size, 8GiB stored payload and a 600-second operation deadline. Flags can reduce entry/payload limits and select a deadline up to one hour. Memory is bounded by the manifest, finite metadata inventory and 1MiB data buffers; logical zero ranges still require bounded-time hashing. An empty target with enough real backing capacity is required; requested PVC capacity remains unenforced.

The archive is published exclusively with mode 0600 outside the source tree, fsynced and never overwritten. Copy it outside the cluster/source failure domain, verify SHA256 and complete --verify before treating it as a backup. A helper's emptyDir alone is not an external backup. The format is plaintext and its checksums are not signatures. Verify against a trusted independently recorded digest, and protect/encrypt/authenticate the external artifact through the operator's backup system.

Current source reports deadline_exceeded for the tool's configured alarm and filesystem_timeout for a filesystem ETIMEDOUT. Failure JSON adds the bounded operation phase, failure source and numeric errno/name; permission and disk-full errors have separate categories. It excludes paths, file contents and exception text. Earlier tool versions used deadline_exceeded for both timeout sources, so that historical category alone cannot identify the cause. Check the actual tool source/version and exit status; an incomplete operation is not a verified backup, even if an archive file exists.

Explicit operator records

Both tools require a small identity JSON containing exactly volume, generation, claimUID. Resolve these from the exact bound PVC/PV and owned volume ConfigMap, never from a reused name. The backup record is:

{
  "version": 1,
  "purpose": "backup-quiesced",
  "source": {"volume": "rv-source", "generation": "original-generation", "claimUID": "original-claim"},
  "recordID": "incident-or-change-id",
  "operator": "responsible-operator",
  "method": "documented application stop and descriptor close",
  "evidenceReference": "private audited evidence location",
  "operatorAcknowledged": true
}

Restore requires the same source in a record with purpose restore-isolated and a new destination identity whose three fields all differ. This record is an operator audit acknowledgement, not cryptographic or automatic proof of physical fencing. The operator must supply real isolation evidence. For a controlled recovery, record exact old consumer Pod absence, no old FUSE mounts on every original Ready node, and separate immutable old/new identities. For unavailable/hostile nodes or an irretrievably lost cluster, use verified infrastructure isolation, revoked application access and a deliberate routing cutover. API Node/Pod deletion and NotReady alone do not prove old clients or storage stopped. Do not promote the restored application until that isolation and accepted recovery point are reviewed.

Commands and completion

The Python tools are source files, not executables bundled in the scratch role images. Provide them in an approved Python environment with the application PVC and external archive path mounted. Example /tools paths below refer to that operator-provided environment. The commands do not create helper Pods or modify a deployment by themselves.

Inside a bounded helper, with the quiesced source mounted at /data and an independent export path at /backup:

python3 /tools/backup-volume.py --root /data --archive /backup/source.takbak \
  --identity /backup/source-identity.json --record /backup/quiescence.json
python3 /tools/backup-volume.py --verify --archive /backup/source.takbak

After copying to independently protected storage, run --verify there too. Copy that external artifact into a fresh restore helper. Keep all target application clients stopped; mount only the new empty PVC and run:

python3 /tools/restore-volume.py --root /data --archive /backup/source.takbak \
  --identity /backup/target-identity.json --record /backup/isolation.json

The whole archive is validated before destination changes. The destination must be empty; no merge or overwrite is available. Creation first fsyncs an incomplete marker and root directory. Final data and inode metadata, child directories and root namespace are fsynced; the marker is removed last and root is synced again. Actual destination hashes, metadata and link relationships are checked before PASS. Failure leaves the new volume unusable for cutover. A failure after marker unlink is explicitly restore_publication_uncertain_keep_clients_stopped, even if marker recreation itself fails. Never interpret missing marker alone as success. Preserve the failed target for diagnosis or delete it normally and allocate another fresh target; the tool will not resume a partial tree.

JSON results and optional exclusive Prometheus textfiles expose bounded operation/result/duration, aggregate sizes and archive hashes, without paths, file contents, operator-record contents or credentials. A PASS does not prove application-level consistency, physical old-node fencing or a backup scheduler's retention policy. Independently read back the restored application files from a new mount before cutover and archive its evidence.

Permanent node loss and cleanup

Current replacement still needs affirmative original-member serving fencing. Deletion also preserves original Node UID/local CSI/backing authority and waits for actual local CSI reclamation. If the original Node/disk is permanently gone, these operations remain blocked; returning the original authority is the normal supported completion path. External restoration into a new volume can recover application service without adopting that uncertain authority, but it does not reclaim an unreachable old disk or authorize removing its finalizers.

Closing that gap requires a reviewed infrastructure fencing/lost-disk attestation contract and backing-driver cleanup support. Permanent-node recovery/disposal remains PARK-09. Old recovery reports retain their historical scope; external restoration does not reclaim old storage or authorize force-delete operations.