Immutable data storage refers to a method of storing data where once a piece of data is written, it cannot be modified or deleted. Instead, any changes to the data result in the creation of a new version. This approach offers several advantages over traditional mutable data storage methods. Immudb Vault is the leading cloud solution to store and share data immutably. See https://vault.immudb.io
immudb vault is based on the industry-leading immutable database, immudb (www.immudb.io). It is a lightweight, high-performance immutable database that provides cryptographic verification and tamper-proof audibility.
It is designed to store and manage critical data in a secure and efficient manner. It supports ACID transactions and can store data in either key/value, SQL, or document model. immudb is most commonly used in applications that require strong data integrity guarantees, such as financial systems, supply chain management, and healthcare applications.
In this blog, we will explore the benefits of storing data immutably and discuss how to store a file in the immudb vault using a bash script with curl.
Immudb Vault makes it very easy to store and retrieve data. Below is an example using a Linux shell script in Bash storing a JSON file in immudb Vault.
#!/bin/bash
IMMUDB_API_TOKEN="your_api_token"
FILE_PATH="/path/to/your/file"
curl -X "PUT" "https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/document" \
-H "accept: application/json" \
-H "X-API-Key: $IMMUDB_API_TOKEN" \
-H "Content-Type: application/json" \
-d @"$FILE_PATH"
Make sure to replace "your_api_token" with the API token you obtained from the immudb vault service at https://vault.immudb.io, and "/path/to/your/file" with the actual path to the file you want to store.
Run the script: Open a terminal, navigate to the directory where you saved the bash script, and execute it using the following command:bash script_name.sh
Replace "script_name.sh" with the actual name of your bash script.
Upon successful execution, the file will be stored in the immudb vault, ensuring its immutability and providing the associated advantages discussed earlier.
You (or somebody else that you want to share data with) can then retrieve the file by doing:
IMMUDB_API_RO_TOKEN="your_read-only_api_token"
curl -sX ”POST” “https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/documents/search” \
-H “accept: application/json” \
-H ”X-API-Key: $IMMUDB_API_RO_TOKEN” \
-H “Content-Type: application/json” \
-d ”{'page':1,'perPage':1}”
In case you need nicer formatting you can use jq (i. e. sudo apt install jq
):
IMMUDB_API_RO_TOKEN="your_read-only_api_token"
curl -sX ”POST” “https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/documents/search” \
-H “accept: application/json” \
-H ”X-API-Key: $IMMUDB_API_RO_TOKEN” \
-H “Content-Type: application/json” \
-d ”{'page':1,'perPage':1}” | jq '.'
In conclusion, storing data immutably offers numerous advantages in terms of data integrity, auditability, security, and simplified data replication. By leveraging immudb's immutable database and following the steps outlined above, you can securely store files in the immudb vault and harness the benefits of immutable data storage.