How to backup PVC regularly

Viewed 4672

What can be done to backup kubernetes PVC regularly for GCP and AWS?

GCP has VolumeSnapshot but I'm not sure how to schedule it, like every hour or every day.

I also tried Gemini/fairwinds but I get the following error when for GCP. I installed the charts as mentioned in README.MD and I can't find anyone else encountering the same error.

error: unable to recognize "backup-test.yml": no matches for kind "SnapshotGroup" in version "gemini.fairwinds.com/v1beta1"
4 Answers

You can implement Velero, which gives you tools to back up and restore your Kubernetes cluster resources and persistent volumes.

Agree with @hdhruna - Velero is really the most popular tool for doing that task.

However, you can also try miracle2k/k8s-snapshots

Automatic Volume Snapshots on Kubernetes

How is it useful? Simply add an annotation to your PersistentVolume or PersistentVolumeClaim resources, and let this tool create and expire snapshots according to your specifications.

Supported Environments:

Google Compute Engine disks, AWS EBS disks.

I evaluated multiple solutions including k8s CSI VolumeSnapshots, https://stash.run/, https://github.com/miracle2k/k8s-snapshots and CGP disks snapshots.

The best one in my opinion, is using k8s native implementation of snapshots via CSI driver, that is if you have a cluster version > = 1.17. This allows snapshoting volumes while in use, doesn't require having a read many or write many volume like stash. I chose gemini by fairwinds also to automate backup creation and deletion and restoration and it works like a charm.

I believe your problem is caused by that missing CRD from gemini in your cluster. Verify that the CRD is installed correctly and also that the version installed is indeed the version you are trying to use.

My installation went flawlessly using their install guide with Helm.

Unfortunately, Velero only allows you to backup & restore PV, not PVCs.

Velero’s restic integration backs up data from volumes by accessing the node’s filesystem, on which the pod is running. For this reason, restic integration can only backup volumes that are mounted by a pod and not directly from the PVC.

Might wanna look into stash.run

Related