If you’re running MYSQL or PostgreSQL in Tanzu, you may have wondered, are my backups really enough?

With stateful apps becoming more common in Kubernetes environments, relying on traditional VM snapshots just does not work anymore. To truly protect your data, you need a Kubernetes -native approach that ensures consistency, fast recovery, and compliance with enterprise standards.

In this guide, we’ll explore:

  • Why VM-level backups fall short for Kubernetes
  • How to back up persistent volumes using CSI snapshots
  • Application-aware strategies for protecting databases
  • Best practices for recovery and automation in Tanzu clusters

Why VM Backups Are Not Enough in Kubernetes

Many organizations deploy their Tanzu clusters on virtual machines and assume that backing up the VM will protect the workloads inside. Unfortunately, this approach fails to meet the needs of stateful Kubernetes applications for a few key reasons:

  • Lack of Application Consistency: VM snapshots don’t coordinate with database flushes or quiescing, leading to potential data corruption.
  • Granularity Issues: You can’t easily restore individual namespaces, pods, or PVCs from a VM-level backup.
  • Poor Integration: VM backups aren’t aware of Kubernetes objects like PVCs, StatefulSets, or CSI volumes.
  • Bottom line: If you care about recoverable and consistent data, VM-level backup isn’t enough.

Backing Up Persistent Volumes with Kubernetes CSI Snapshots

The Container Storage Interface (CSI) provides a Kubernetes-native way to snapshot and back up persistent volumes. Tanzu supports CSI snapshots through various compatible storage providers.

How CSI Snapshots Work:

  1. VolumeSnapshotClass: Defines the CSI driver and snapshot type.
  2. VolumeSnapshot: Triggers a snapshot of a specific PVC.
  3. VolumeSnapshotContent: Stores the snapshot data for future restore.

These objects are managed declaratively with kubectl or via backup platforms that support Kubernetes-native storage like CloudCasa or Velero.

✅ Tip: Schedule recurring snapshots with retention policies for better RPO/RTO.

Application-Aware Backups for Databases (MySQL, PostgreSQL, etc.)

For databases, raw volume snapshots are not enough—you need to ensure the application is in a consistent state before taking the snapshot.

Options for Application-Aware Backups:

  • Pre/Post Hooks: Use lifecycle hooks to run mysqldump or pg_dump before the snapshot is taken.
  • Sidecar Containers: Run backup logic as part of the pod spec using sidecars.
  • Backup Tools Integration: Tools like CloudCasa and Velero offer hooks and native support for MySQL and PostgreSQL.

Here’s an example of a pre-backup hook for PostgreSQL:

hooks:
  pre:
    - exec:
        container: postgres
        command: ["pg_dump", "-U", "user", "-d", "mydb", "-f", "/backup/mydb.sql"]

⚠️ Make sure your backup data is stored outside of the cluster, preferably in an object store like Amazon S3 or Azure Blob.

Best Practices for Tanzu Persistent Volume and Database Backup

  1. Use CSI-compatible storage that supports snapshotting (e.g., vSphere CSI, AWS EBS, Azure Disk).
  2. Automate backups using Kubernetes CRDs or external backup solutions with native integration.
  3. Enable application-aware hooks to ensure data consistency.
  4. Store backups offsite and test restores regularly.
  5. Label resources for easier backup targeting and policy enforcement.

Recovery Scenarios: From PVC Loss to Cluster-Wide Failures

Being prepared to restore data matters just as much as taking backups.

Common Restore Scenarios:

ScenarioSolution
Deleted PVC or podRestore from snapshot or backup image
Namespace corruptionRestore entire namespace with resources
Full cluster recoveryRestore etcd, workloads, and PVCs to new cluster
Database-level data lossRestore from logical dump (e.g., SQL file)

🔄 Test restores in a staging cluster regularly to validate your disaster recovery plan.

Conclusion

Backing up stateful applications in Tanzu Kubernetes isn’t just about taking VM snapshots—it’s about using Kubernetes-native tools and practices to ensure data integrity, fast recovery, and compliance. Leverage CSI snapshots, application-aware hooks, and robust backup platforms to safeguard your persistent data.

If you’re running production workloads in Tanzu, make backup and restore a core part of your DevOps strategy.

Want to see how CloudCasa protects your Tanzu workloads?  ⬇️ Try it yourself today.