Backup / Disaster Recovery in Hyperledger Fabric
Hyperledger Fabric provides simple mechanism for taking backup of your ledgerdata & Statedatabse (Couchdb). Intention is to mount the volumes of Peer / Orderer storage volumes to backup volumes. i.e both Orderer & Peer storage resides at /var/hyperledger/production (Default location) . If we are able to mount this volumes from container to our localhost and use the same for building our network then the chanicodes, channel , data would all persist.
Example :
- /mybackuppath/orderer:/var/hyperledger/production
The above line should be included in docker-composer of orderer volumes.
What should you do if you have not provided backup volume & you are already running your network ?
You can copy the Orderer & Peer storage volumes using the docker cp & path where you want the back up to be stored. You could then add the backup path to docker-compose.yml & bring up the network to be persistent.
Example :
docker cp myorderercontainerid:/var/hyperledger/production /mybackuppath/ordrererbackup
Should we take backup of Couchdb(State database) ?
This is optional since we have taken backup of ledgersdata , Peer would ensure pushing data from ledgersdata to its state database.
A word of caution is to make sure when we take backup of couchdb the records are either less than or equal ledgersdata but never more than the ledgersdata as this would place the peer & statedatabase out of sync.