skip to content
Ruban Selvarajah

Making a backup of your Persistent Volumes in GKE

/ 1 min read

There is a recommended way for doing this, but it’s not applicable for my case. Apparently the PV for my Bitnami Moodle cluster was provisioned with an in-tree persistent disk driver which does not support snapshots.

In order to make use of the volume snapshot feature, I have to delete then recreate my PV with a new storage class that has the CSI provisioner, which will be a disruptive change.Readmore

I can’t afford a service disruption at this point in time so I’m using the trusted cp tool instead.

Let’s 🚀

The official approach

Using GKE’s volume snapshot feature

  1. Create a VolumeSnapshotClass object to specify the CSI driver and deletionPolicy for your volume snapshots

    Terminal window
    kubectl apply -f moodle-cluster-volumesnapshotclass.yaml
  2. Create a VolumeSnapshot object — a request to GKE to create a snapshot of an existing PersistentVolumeClaim object

    Terminal window
    kubectl apply -f volumesnapshot.yaml
  3. Confirm that GKE created the VolumeSnapshotContents object

    If empty - check GKE logs (filter for Warnings)

    Terminal window
    kubectl get volumesnapshotcontents

Of course that doesn’t work for me so I stopped here.

The cop-out solution

Using the plain old cp and kubectl cp

Terminal window
#In the pod
cp -r /bitnami/moodle /opt/bitnami/bitnami-20230401/moodle
cp -r /bitnami/moodledata /opt/bitnami/bitnami-20230401/moodledata
cd /opt/bitnami
zip -r bitnami-20230401
Terminal window
#In my PC
kubectl cp moodle-6fb54cb979-zhm7k:/opt/bitnami/ .