Skip to main content

Command Palette

Search for a command to run...

Longhorn — Backup & Restore Volumes

Updated
2 min read

1. Prerequisites

Longhorn installed and healthy (longhorn-system pods ready).

A Backup Target reachable from all Longhorn manager pods:

S3-compatible bucket (with access/secret and optional custom endpoint), or

NFS export (read/write, stable network).

Sufficient free space on the BackupStore.

2.Set the Backup Target

UI (recommended)

  1. Open Longhorn UI → Settings → General.

  2. Set Backup Target (examples):

  • S3: s3://my-bucket@us-east-1/longhorn

  • NFS: nfs://10.0.0.20:/export/longhorn-backups

  1. If using S3, set Backup Target Credential Secret (Access Key, Secret, Region, Endpoint if non-AWS).

kubectl (advanced)

  • Create a Secret with S3 creds in longhorn-system, then patch Settings (keys vary by version). In most cases the UI is simpler and safer.

3. Create Snapshots & Backups

Manual (per volume)

  1. Longhorn UI → Volumes → click your volume.

  2. Snapshots tab → Create Snapshot (name it).

  3. Backups tab → Create Backup from the snapshot (or directly “Backup”).

Recurring (recommended)

  • Per volume → Recurring Jobs:

    • Hourly/Daily Snapshot (e.g., keep last 7)
    • Daily/Weekly Backup (e.g., keep last 30)
  • Attach the recurring job(s) to the volume (or set globally and opt-in).

4. Verify Backups

UI

  • Volume → Backups tab → you should see backup entries with timestamps and sizes.

  • Click a backup to view details (labels, CRC, etc.).

Best practice

  • Periodically restore a backup to a scratch/test volume and run a quick read/write check.

5. Restore a Backup (New Volume)

UI

  1. Longhorn UI → Backups (left menu).

  2. Choose the Backup Volume (it groups backups by original volume).

  3. Pick the desired Backup → Restore.

  4. Set New Volume Name, size (auto from backup), Data Engine, # of replicas, and (optional) Create PV/PVC.

  5. Click OK. Longhorn creates the volume and starts rebuilding replicas.

  6. When the volume is Healthy, Attach it to a node, then mount it via your workload (or use the auto-created PVC).

Notes

  • If you created PV/PVC automatically, just point your Pod/Deployment/StatefulSet to that PVC.

  • File system (ext4/xfs) will match the original backup unless you override.

6. Disaster Recovery (Cross-cluster or Failover)

DR Volume approach

  1. On the target cluster, configure the same Backup Target.

  2. Longhorn UI → Backups → select the source Backup Volume.

  3. Click Create Disaster Recovery Volume (DR Volume).

  4. Longhorn creates a DR volume that periodically pulls incremental backups.

  5. If the source cluster goes down, Activate the DR volume:

  • DR Volume → Activate → it becomes a regular volume.

  • Attach, and use like normal.

When to use

  • For warm standby and faster RTO than restoring from scratch.