Skip to content

How to Snapshot and Rollback a MySQL Helm Release on OpenShift

Blog | 06.26.2019 | 3 min read

Ramendra Singh

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  • Share on Twitter
  • Share on Linked In
  • Share on Facebook
  • Email this blog post

In this tutorial, we will create a snapshot of the MySQL database that is deployed on OpenShift. We will then restore the database state using the roll back to a point-in-time snapshot feature.

Before you begin this tutorial, make sure you have installed Robin Storage on your existing OpenShift cluster, and your MySQL database is deployed on OpenShift, has data loaded in it, and the Helm release is registered with Robin.

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

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 snap9movies movies --desc "contains 9 movies" --wait

Let us verify we have successfully created the snapshot.

robin snapshot list --app movies

You should see an output similar to this:

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

Rolling back to a point-in-time using snapshot

We have 9 rows in our “movies” table. To test the snapshot and rollback functionality, let’s simulate a user error by deleting one movie, “June 9”, from the “movies” table.

mysql -h $IP_ADDRESS -u root -p$MYSQL_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$MYSQL_PASSWORD testdb -e "SELECT * from movies;"

You should see the row with the movie “June 9” does not exist in the table anymore.

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

robin app info movies

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

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

robin app rollback movies 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$MYSQL_PASSWORD testdb -e "SELECT * from movies;"

You should see an output similar to the following:

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

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

Related Posts​