Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 201Kubernetes · Backup

How to back up Kubernetes with Velero

An etcd snapshot saves the cluster state, but not the data in your volumes — and you cannot restore one namespace from it. Velero backs up Kubernetes objects and volume data per namespace into S3-compatible storage, on a schedule, and restores them into the same or another cluster (also a restore into a new namespace for a test). This how-to backs up a namespace, schedules daily backups, and does a real restore test.

  • 5 Lessen
  • 3 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

201.1

The quick answer

velero backup create shop-$(date +%F) --include-namespaces shop --wait
velero backup describe shop-$(date +%F) --details
velero schedule create shop-daily --schedule="0 2 * * *" --include-namespaces shop --ttl 720h
velero restore create shop-test --from-backup shop-$(date +%F) --namespace-mappings shop:shop-restore-test --wait

Commando's in deze les

201.2

Step by step

  1. Install Velero with a bucket and the node agent for file-system volume backup (see the full guide). Check that the storage location is Available:
velero backup-location get
  1. First manual backup (quick answer, line 1) — --wait waits until it is done. Phase: Completed is good; PartiallyFailed needs a look at velero backup logs NAME.
  2. Volume data — with --default-volumes-to-fs-backup at install time, the node agent copies every volume's files. Or use CSI snapshots where your storage supports them. Check describe --details: each volume must be listed under "Pod Volume Backups" or "CSI Snapshots".
  3. Schedule (line 3) — every night at 02:00, kept for 30 days (--ttl 720h). Add a separate weekly schedule with a longer TTL if needed.
  4. Restore test into a new namespace (line 4) — --namespace-mappings restores shop as shop-restore-test, so production is not touched. Check the Pods start and the data is there, then delete the test namespace.
  5. Real restore — delete or empty the broken namespace first; Velero does not overwrite existing objects by default (--existing-resource-policy update changes that).
  6. Before risky changes — a manual backup before a cluster upgrade or a big Helm change costs one minute.
  7. Protect the backups — the bucket in another account or region, versioning or object lock, and an alert when a backup fails (velero_backup_failure_total metric, or check velero backup get daily).

201.3

Check that it worked

velero backup get shows daily backups with STATUS Completed; the restore test shows Phase: Completed, and in shop-restore-test the app runs with the same data (for example the same row count in its database).

201.4

Common problems

ProblemCauseFix
Backup location UnavailableWrong bucket, region, endpoint or credentials.velero backup-location get; check the secret and s3Url.
PartiallyFailedSome objects or volumes failed.velero backup logs NAME | grep -i error.
Volume data missing after restoreOnly objects were backed up.Node agent with fs-backup, or CSI snapshots; check --details.
Restore skips objectsThey already exist in the target.Restore into a new namespace, or delete first; --existing-resource-policy update.
Restored Pods stay PendingStorageClass or node differs in the new cluster.Map storage classes (Velero ConfigMap); check PVC events.
Backups fill the bucketNo TTL or old schedules.--ttl; delete old schedules; bucket lifecycle as a second guard.

201.5

Go further

1What does Velero save that an etcd snapshot does not?

The data in persistent volumes, and backups per namespace that can be restored on their own or into another cluster.

2Why restore into a new namespace for a test?

It proves the backup works without touching the running production namespace.

Alle commando's in dit hoofdstuk