How to Snapshot and Rollback a MariaDB Helm Release on GKE

By May 20, 2019 June 25th, 2019 Blog, Kubernetes, storage

In this tutorial, we will create a snapshot of the MariaDB database that has been deployed on Google Kubernetes Engine (GKE). We will then restore the database state using the roll back to a point-in-time snapshot feature.

Before starting with this tutorial, make sure ROBIN Storage is installed on GKE, and your MariaDB database is deployed, has data loaded in it, and the Helm release is registered with ROBIN.

Creating a snapshot of the MariaDB Helm Release

Snapshots allow you to restore your application’s state to a point-in-time. If you make a mistake, such as unintentionally deleting important data, you can simply undo it by restoring a snapshot.

ROBIN lets you snapshot not just the storage volumes (PVCs) but the entire database application including all its resources such as Pods, StatefulSets, PVCs, Services, ConfigMaps, etc. with a single command. To create a snapshot, run the following command.

robin snapshot create 9-movies myfilms --desc "contains 9 movies" --wait

Let’s verify we have successfully created the snapshot.

robin snapshot list --app myfilms

You should see an output similar to this:

Snapshot entire database application including all its resources - Pods, StatefulSets, PVCs (Storage Volumes, Services, ConfigMaps | MariaDB Snapshot ROBIN

We now have a snapshot of our entire database with information of all 9 movies.

Roll back to a point-in-time using snapshot

Let us simulate a user error by deleting a movie from the “movies” table.

mysql -h $IP_ADDRESS -u root -p$MARIADB_PASSWORD testdb -e "DELETE from movies where title = 'June 9'"

Let us verify the movie titled “June 9” has been deleted.

mysql -h $IP_ADDRESS -u root -p$MARIADB_PASSWORD testdb -e "SELECT * from movies"

You should see the movie does not exist in the table anymore.

Snapshot entire database application including all its resources - Pods, StatefulSets, PVCs (Storage Volumes, Services, ConfigMaps | MariaDB Snapshot ROBIN

Let’s run the following command to see the available snapshots:

robin app info myfilms

You should see an output similar to the following. Note the snapshot id, as we will use it in the next command.

Snapshot entire database application including all its resources - Pods, StatefulSets, PVCs (Storage Volumes, Services, ConfigMaps | MariaDB Snapshot ROBIN

Now, let’s rollback to the point where we had 9 movies, including “June 9”, using the snapshot id displayed above.

robin app rollback myfilms Your_Snapshot_ID --wait

To verify we have rolled back to 9 movies in the “movies” table, run the following command.

mysql -h $IP_ADDRESS -u root -p$MARIADB_PASSWORD testdb -e "SELECT * from movies"

You should see an output similar to the following:

We have successfully rolled back to our original state with 9 movies!

This concludes the Snapshot MariaDB on GKE tutorial. We can also clone entire MariaDB database to improve collaboration across Dev/Test/Ops teams.

mm

Author Ankur Desai, Director Products

More posts by Ankur Desai, Director Products