Skip to content

[feature]: Cluster backup and restore commands (Velero-inspired) #1836

@devantler

Description

@devantler

User Story

As a Kubernetes operator,
I want ksail cluster backup and ksail cluster restore commands,
So that I can backup and restore a cluster's Kubernetes resources and persistent volumes for disaster recovery or cluster migration.

Acceptance Criteria

Backup Command (ksail cluster backup)

  • Creates a backup archive (.tar.gz) containing Kubernetes resources and volume data.
  • Backs up all Kubernetes resources as YAML files organized by namespace (similar to Velero's tarball approach).
  • Backs up persistent volume data using file system backup (copying data from PVCs).
  • Includes a backup.yaml metadata file with: version, timestamp, cluster name, distribution, provider, and list of backed-up resources.
  • Supports --include-volumes flag to back up persistent volume data (default: true).
  • Backs up resources in a consistent order (CRDs → Namespaces → StorageClasses → PVs → PVCs → Secrets → ConfigMaps → Services → Deployments → etc.).

Restore Command (ksail cluster restore)

  • Restores Kubernetes resources from a backup archive to a target cluster.
  • Restores resources in the correct order (CRDs first, then namespaces, then storage resources, then workloads).
  • Restores persistent volume data by provisioning new PVCs and copying data back.
  • Supports --existing-resource-policy flag with options: none (skip existing, default) or update (patch existing resources).
  • Labels restored resources with ksail.io/backup-name and ksail.io/restore-name for traceability.

Limitations (v1)

  • No secret encryption in v1 (secrets exported as plain YAML - recommend using SOPS separately).
  • No cloud provider volume snapshots in v1 (uses file system backup approach only).
  • No Hetzner/block storage snapshots in v1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions