Backup and restore
A Kuben installation is three kinds of state, backed up in three ways.
| State | Where it lives | Back up with |
|---|---|---|
| Desired state: projects, environments, apps, releases | Kubernetes custom resources | kuben backup |
| Identity and history: users, tokens, memberships, audit log | SQLite on the PVC, or PostgreSQL | a VolumeSnapshot of the PVC, or pg_dump |
| App data | PVCs in the environment namespaces | VolumeSnapshots or Velero |
Export the custom resources
Section titled “Export the custom resources”kuben backup --out ./kuben-backupFrom inside the chart:
kubectl -n kuben-system exec deploy/kuben -- /kuben backup --out /tmp/kuben-backupkubectl -n kuben-system cp kuben-0:/tmp/kuben-backup ./kuben-backup # adjust the pod nameThe directory holds every Project, Environment and App as YAML, plus the KubenConfig.
Restore
Section titled “Restore”kuben restore --from ./kuben-backupRestore does three things in order:
- Applies the CRDs first, so the objects have a schema to land in.
- Re-points old
ownerReferences at the newProjectuids. Without this the garbage collector would delete the restored environments and apps as orphans. - Creates the namespaces immediately, so restored apps can be reconciled without waiting for the environment controller.
After a restore, the SQL side still references the old cluster objects by uid. Restore the database from the same point in time as the export, or accept that release history before the restore is not linked to the restored apps.
A practical schedule
Section titled “A practical schedule”- Nightly:
kuben backupto object storage, and aVolumeSnapshotof the Kuben PVC (orpg_dump). - Before an upgrade: the same, by hand. See Upgrading.
- App volumes: on the schedule your data needs, with the snapshot tooling of your storage class.
The export is plain YAML, so it also works as a change log: commit it to a repository and diff between days.