In the last part of this series, we saw how to configure a highly available WordPress deployment with Portworx, a data and storage management platform for Kubernetes. In the current installment, we will learn how to implement the backup and restore of PVCs through local and remote snapshots feature of Portworx.

Snapshots in Portworx

Portworx can take point-in-time snapshots of a PVC which can be stored locally within the cluster or remotely in an object storage service compatible with Amazon S3 API. The remote snapshots called CloudSnaps promise higher availability due to the fact that they are stored outside of the cluster.

When running distributed databases as statefulsets in Kubernetes, taking snapshots of individual PVCs associated with each pod of the statefulset may not result in an application-consistent backup. To enable backing up a group of PVCs that logically belong to an application, Portworx has a concept called 3DSnaps.

When using 3DSnaps, Portworx allows specifying pre and post rules that are run on the application pods using the volumes. This allows users to quiesce the applications before the snapshot is taken and resume I/O after the snapshot is taken. The commands will be run within pods with attached PVC that are being snapshotted.

Whether it is a snapshot of a single PVC or a group of PVCs taken through a 3DSnap, the backup process can be either on-demand or scheduled.

Read More:   Best Software Solutions for Logistics Companies in 2022

Let’s see how to create a CloudSnap to backup MySQL and WordPress PVCs to a remote site. For simplicity, we will use MinIO running in a machine outside of the cluster for storing the snapshots. Since it is 100% compatible with Amazon S3 API, Portworx can be pointed to MinIO to store CloudSnaps.

Running MinIO on Docker

On a Linux or macOS machine running Docker, create a directory to mount the volume for MinIO.

Run the below command to launch MinIO container with a volume pointing to the above directory.

We are using the example access key and secret key as mentioned in MinIO’s documentation. For production usage, replace them with your own keys.

Verify by accessing the MinIO UI available at port 9000.

Sign in with the access key and secret key to access MinIO browser.

Registering MinIO with Portworx

Before we can initiate the backup process, we need to tell Portworx where to store the snapshots. This is done by creating a credential within Portworx with the access key and secret key of MinIO.

Let’s invoke the CLI of Portworx, pxctl, running inside one of the pods of the daemonset within the kube-system namespace, and pass the parameters required to create the credentials.

Verify the credentials by listing them with the below command:

With the object store credentials in place, we are ready to configure CloudSnaps.

Read More:   Update Startup Run:AI Looks to Improve GPU Utilization for AI Workloads

Configuring Portworx CloudSnaps for MySQL and WordPress

If you recall, the application deployment resulted in two PVCs associated with MySQL and WordPress. Our goal is to backup these PVCs through CloudSnaps.

The below YAML specification creates a CloudSnap for PVC, db-pvc used by MySQL pod.

Similarly, let’s create a snapshot for WordPress PVC.

List and verify the snapshots with the below commands:

The above output confirms that the snapshots have been successfully created.

Refer to Portworx documentation on how to schedule the snapshots to enable periodic backups.

Finally, if you access MinIO browser, you notice that there are two folders created in a bucket. These folders are storing the snapshots from the two PVCs.

Restoring from CloudSnaps

Let’s create new PVCs from the snapshots stored in MinIO.

The below YAML specification results in a new MySQL PVC which is a clone of the original PVC.

Notice the storage class name, stork-snapshot-sc, which is specific to Portworx’s Storage Orchestrator for Kubernetes (STORK) that manages the orchestration and operations of stateful workloads.

Read More:   Update New Anaconda Package Embeds Python on Cloudera Hadoop

Let’s also create a PVC clone for WordPress.

When we apply these two specs, a couple of new PVCs are created.

The PVCs ending with “*-clone” with storage class stork-snapshot-sc are new PVCs restored from the snapshots.

You can now create WordPress and MySQL pods using the cloned PVCs of the original pods. This technique can be used to migrate PVCs from one namespace to another or even other clusters running Portworx.

In the next part of this series, we will explore how to migrate the entire workload from one cluster to another using Portworx and Velero. Stay tuned!

Janakiram MSV’s Webinar series, “Machine Intelligence and Modern Infrastructure (MI2)” offers informative and insightful sessions covering cutting-edge technologies. Sign up for the upcoming MI2 webinar at

Portworx is a sponsor of InApps.

Feature image by Paul Brennan from Pixabay.

InApps is a wholly owned subsidiary of Insight Partners, an investor in the following companies mentioned in this article: Docker.