Resetting and snapshotting a node

Database locations

The data of a blockchain application is stored in the following key-value stores:

blockchain.db

Stores blocks, transactions and states.

node.db

Stores peer data, or data unique to each node.

forger.db

Stores forging data which is unique to each delegate. Important for enabling forging.

All databases are located under ~/.lisk/BAPP-NAME/data/

If plugins are registered in the application, they will have a separate key-value store for each plugin for the plugin-specific off-chain data under ~/.lisk/BAPP-NAME/plugins/data/.

Resetting the blockchain

This will remove all existing on-chain data of the blockchain application!
Please note that the blockchain height will be reset back to 1 again the next time the application is started, and all existing accounts will be deleted. In addition, the genesis accounts will be reset to the state defined in the respective genesis block.

To reset the blockchain data of an application, it is therefore only necessary to reset the blockchain.db.

This can be achieved by using the blockchain:reset command of the application CLI.

Before using the command, ensure the application is stopped and is not running anymore.
bin/run blockchain:reset

Creating snapshots of the blockchain

To export the blockchain data of an application, run the following command:

Before using the command, ensure the application is stopped and is not running anymore.
$ bin/run blockchain:export

A command reference can be viewed by adding the --help parameter:

% bin/run blockchain:export --help
Export to <FILE>.

USAGE
  $ hello_app blockchain:export

OPTIONS
  -d, --data-path=data-path  Directory path to specify where the node data is stored. Environment variable
                             "LISK_DATA_PATH" can also be used.

  -o, --output=output        The output directory. Default will set to current working directory.

EXAMPLES
  blockchain:export
  blockchain:export --data-path ./data --output ./my/path/

Importing a snapshot

To import a snapshot of blockchain data, run the following command:

Before using the command, ensure the application is stopped and is not running anymore.
bin/run blockchain:import blockchain.db.tar.gz

A command reference can be viewed by adding the --help parameter:

% bin/run blockchain:import --help
Import from <FILE>.

USAGE
  $ hello_app blockchain:import FILEPATH

ARGUMENTS
  FILEPATH  Path to the gzipped blockchain data.

OPTIONS
  -d, --data-path=data-path  Directory path to specify where the node data is stored. Environment variable
                             "LISK_DATA_PATH" can also be used.

  -f, --force                Delete and overwrite existing blockchain data

EXAMPLES
  blockchain:import ./path/to/blockchain.db.tar.gz
  blockchain:import ./path/to/blockchain.db.tar.gz --data-path ./lisk/
  blockchain:import ./path/to/blockchain.db.tar.gz --data-path ./lisk/ --force