K8sCalc

storage

Longhorn S3 Backup Config Generator

Generate Longhorn S3 backup configuration: credentials Secret, BackupTarget settings, StorageClass, and RecurringJob YAML. Works with Hetzner Object Storage, AWS S3, and any S3-compatible endpoint.

Longhorn S3 Backup Architecture

Longhorn provides two levels of data protection: local snapshots (on-disk) and remote backups (S3). For true disaster recovery — surviving a full cluster loss — you need remote S3 backups.

Backup vs Snapshot

SnapshotBackup
Storage locationSame disk as volumeS3 (remote)
Survives node failurePartially (with replicas)Yes
Survives cluster lossNoYes
SpeedFastSlower (upload)
Use caseQuick recovery, devDisaster recovery

Backup Process

  1. 1.Longhorn takes a volume snapshot
  2. 2.Computes incremental diff since last backup
  3. 3.Compresses and uploads delta blocks to S3
  4. 4.Updates backup metadata

The incremental nature means backups after the first are small — only changed blocks are uploaded.

Hetzner Object Storage Setup

  1. 1.Create bucket: Hetzner Console → Object Storage → Create Bucket
  2. 2.Generate credentials: Object Storage → Access Keys → Add Key
  3. 3.Use endpoint: https://s3.eu-central-1.amazonaws.com
  4. 4.Region: eu-central-1

Hetzner S3 costs €0.0119/GB/month — a 100 GB backup costs ~€1.19/month.

RecurringJob Groups

Longhorn uses RecurringJob groups to apply backup schedules to volumes. When you create a StorageClass with recurringJobSelector: '[{"name":"backup","isGroup":true}]', all volumes created from that StorageClass automatically inherit the backup schedule.

Frequently Asked Questions

Does Longhorn support Hetzner Object Storage as a backup target?

Yes. Hetzner Object Storage is S3-compatible. Use the endpoint https://s3.eu-central-1.amazonaws.com with region eu-central-1. Create the bucket in the Hetzner Console and generate an access key under Object Storage → Access Keys.

What is a RecurringJob in Longhorn?

A RecurringJob is a Longhorn CRD that defines scheduled snapshot or backup operations. The 'backup' task takes a snapshot and uploads it to the configured S3 target. The 'snapshot' task only takes a local snapshot without uploading. For disaster recovery, always use 'backup' to push to S3.

How do I restore a Longhorn volume from S3 backup?

In Longhorn UI: Backup → select your backup → Restore. You can restore to a new PVC or directly replace an existing volume. For full cluster disaster recovery, restore etcd first (the cluster state), then restore Longhorn volumes.

Is the access key stored securely in the generated YAML?

The generated YAML uses placeholder values (YOUR_ACCESS_KEY_ID). Replace these before applying. In production, use an external secrets manager (Vault, Sealed Secrets) to inject the secret, rather than storing credentials in plain YAML files or Git.