How to Snapshot a CouchDB Helm Release on GKE

By May 28, 2019 June 3rd, 2019 Blog, Kubernetes, storage

In this tutorial, we will create a snapshot of the CouchDB database that has been deployed on Google Kubernetes Engine (GKE). We can then alter the clone records and verify that the data from the parent database remains intact.

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

Snapshots enable 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 the database using a snapshot taken earlier.

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 of your CouchDB database, run the following command.

robin snapshot create snap-5-records couch --desc "contains 5 documents" --wait

Let’s verify we have successfully created the snapshot.

robin snapshot list --app couch

You should see an output similar to this:

We now have a snapshot of our entire database that includes all robindb data.

Rolling back to a point-in-time using snapshot

Let us now simulate a user error by deleting the database robindb. Run the following command to delete robindb database.

curl -X DELETE http://$COUCHDB_USER:$COUCHDB_PASSWORD@$IP_ADDRESS:5984/robindb

Let us verify that the robindb database has been deleted.

curl -X GET http://$COUCHDB_USER:$COUCHDB_PASSWORD@$IP_ADDRESS:5984/robindb

The above command should give the following output:

{"error":"not_found","reason":"Database does not exist."}

Let us run the following command to see the available snapshots:

robin snapshot list --app couch

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

Now, let us roll back to the point in time where we had the robindb database with an employees document and 5 records, using the snapshot id displayed above.

robin app rollback couch Your_Snapshot_ID --wait

Let us now verify that we have rolled back to the state when we had the database robindb intact with employees document and records.

To verify run the following command.

curl -X GET http://$COUCHDB_USER:$COUCHDB_PASSWORD@$IP_ADDRESS:5984/robindb/employees

You should see an output similar to the following:

We have now successfully created a snapshot of our original CouchDB database, and verified that the snapshot of the database also includes the robindb with 5 records under employees document, just as it exists in the original database.

We can now clone the CouchDB database and modify the clone without impacting the original database.

This concludes the Snapshot CouchDB database on GKE tutorial.

mm

Author Madhura Gaunekar

More posts by Madhura Gaunekar