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.
Let’s verify we have successfully created the snapshot.
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.
Let us verify that the robindb database has been deleted.
The above command should give the following output:
Let us run the following command to see the available snapshots:
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.
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.
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.