Hyperledger Fabric Disaster Recovery Methods


(S//Bot) #1

Hyperledger fabric is gaining potential day by day. Many enterprises are trying fabric in their applications. When using large networks involving more number of peers and orderers, it is very essential to maintain a backup of the ledger data. It will help in case there is a network failure. Also, it will help in the development phase as one can use the backup data to perform future tests.

In this article, I will address how to take a backup and how to use the backup in a hyperledger fabric.

Location of Ledger Data in Containers

Generally, the ledger data in a peer is stored in /var/hyperledger/production/ location. And in orderer, it is /var/hyperledger/production/orderer. We need to take a backup of these folders.

Steps to take Backup

Step 1:

To take a backup, it is necessary to create space to store data. As network runs inside Docker containers we shall use volumes to achieve this. I will be using basic-network with one peer, one orderer, one ca and one CouchDB. As we have one peer and one orderer, we need to create two volumes, say backup_orderer and backup_peer. We need to specify these as volumes in docker-compose.yml file as below.

Subscribe to Sudo vs Root

Our newsletter rolls out every 15 days. No fluff. Pure content.

networks:
  basic:
volumes:
  backup_peer:
  backup_orderer:

This will create two volumes at the time of starting a network.

Step 2:

Next step is to mount these volumes to the containers. For peer, we can define volume as shown below.

volumes:
	- backup_peer:/var/hyperledger/production

For orderer, we can define volume as shown below.

volumes:
	- backup_orderer:/var/hyperledger/production/orderer

Now we are ready to start the network by executing docker-compose. All the data that we generate as part of transactions will now get copied to the volumes. One can use the cloud to store the data in volumes.

Peer Backup Underhood

In peers, ledger data gets stored in /var/hyperledger/production. production folder has three subfolders namely chaincodes, ledgersData, transientStore, Inside ledgersData we have six folders namely bookkeeper, chains, configHistory, historyLeveldb, ledgerProvider, pvtdataStore. Inside chains we have two other folders namely chains, index. chains folder has all the channel data, a folder with channel name and complete blockchain of that channel (file blockfile_000000).

Orderer Backup Underhood

In orderer, ledger data gets stored in /var/hyperledger/production. production has orderer folder. orderer has two folders namely chains, index. chains has folders with names of channel and testchainid. All the folders have blockfile_000000.

blockfile_000000 in testchainid contains all the details of the channels. Rest of the blockfile_000000 in other folders deals with ledger data of the channels.

Steps to Use Backup Data

Now we have the backup data. You can find the volumes at /var/lib/docker/volumes in your machine or else in the cloud if you stored there. Mount the end point of volumes to the /var/hyperledger/production of peers and orderers in docker-compose.yml.

Start the network by executing a docker-compose file. As the volumes are mounted, the ledger data will automatically get copied to the new network. There is no need to create channels and join peers, as all the required data is copied to respective folders in containers. Check whether the data is perfect or not by executing queries.

If you have any doubts or stuck somewhere you can comment below and let us know, we will try to answer as soon as possible. 😀


This is a companion discussion topic for the original entry at https://www.skcript.com/svr/hyperledger-fabric-disaster-recovery-methods/

(Rajat Wasan) #2

How can we mount volumes on running networks?


(Varun Raj) #3

You cant mount it to running networks, when you start the network, you need to mount it to local folder.