How to Snapshot and Rollback a Redis Helm Release on OpenShift

In this tutorial, we will create a snapshot of the Redis 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 Redis 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 9-employees empapp --desc "Has 9 employees" --wait
 
 
 

Let us verify we have successfully created the snapshot.

 
 
robin snapshot list --app empapp
 
 
 

You should see an output similar to this:

We now have a snapshot of our entire Redis database with all information about 9 employees.

Rolling back to a point-in-time using snapshot

We have 9 rows in our “employees” hash. To test the snapshot and rollback functionality, let’s simulate a user error by deleting three employees, “e000007”, “e000008” and “e000009” from the “employees” hash.

 
 
redis-cli -h $SERVICE_IP -a $REDIS_PASSWORD hdel employees e000009 redis-cli -h $SERVICE_IP -a $REDIS_PASSWORD hdel employees e000008 redis-cli -h $SERVICE_IP -a $REDIS_PASSWORD hdel employees e000007
 
 
 

Run the following command to check the employee records.

 
 
redis-cli -h $SERVICE_IP -a $REDIS_PASSWORD hvals employees
 
 
 

You should now see that the 3 employee records we just deleted, do not exist in the hash anymore.

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

 
 
robin app info employees
 
 
 

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 employees, including “e000009”, using the snapshot id displayed above.

 
 
robin app rollback empapp Your_Snapshot_ID --wait
 
 

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

 
 
redis-cli -h $SERVICE_IP -a $REDIS_PASSWORD hvals employees
 
 
 

You should see an output similar to the following:

We have successfully rolled back our Redis database to the original state with 9 employee records!

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

Recommended Posts