Backup and restore the node
Gear node stores its data in a dedicated directory.
For example if you run the node as the root user on Linux (
/root) the absolute path of node's data directory will be:
Let's explore the data that the node stores in this directory.
│ └── ...
│ ├── db
│ │ └── full
│ ├── keystore
│ └── network
│ └── full
The node can connect to different chains. The chain can be selected using the
--chain argument. The default chain is the staging test network at the moment. Its data is located in
If you connect to the Vara network, the chain subdirectory name will be
vara_network resulting in the
If you start the node with the
--dev argument, the virtual network in development mode will run with the data stored in the
The database keeps the blockchain state in the local node storage. It synchronizes with other nodes over a peer-to-peer protocol. One can choose the DB format using the
--database argument. Possible options are:
rocksdb(default): use RocksDB as database engine, data is stored in
paritydb: use ParityDB as database engine, data is stored in
paritydb-experimental: deprecated experimental mode of the ParityDB engine (will be removed in future releases), data is stored in
Note that the database contents depends on the pruning mode of the node. By default the node keeps only the last 256 blocks. To keep all the blocks use the
--pruning=archive argument when running the node.
The database can be deleted and synchronized from scratch at any time. Use the
gear purge-chain command to completely delete the DB.
The network private key is used to calculate the unique peer identifier (started with
12D3KooW). This key is stored in
<chain>/network/secret_ed25519 file. The key file is the binary file containing 32 bytes of the Ed25519 (by default) private key. You can use
hexdump command to read the key:
hexdump -e '1/1 "%02x"' /root/.local/share/gear/chains/gear_staging_testnet_v4/network/secret_ed25519
You can override this key by running the node with the
# Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/ws/p2p/12D3KooWMRApe2S5QMdhHwmcDapDxZ7xf2Xa3z2HfCCYoHTmjiXV
If there is no
--node-key argument, the node uses the key from the
secret_ed25519 file. If it does not exist, it is created with a newly generated secret key.
The network key file cannot be recovered if lost. Therefore, you are to keep it (or the private key itself) to have the possibility to run the node with the same peer ID.
Moving the node
To move the node to a new server you are to backup then restore the following (provided paths are for default Staging Testnet V4 node's parameters):
The network private key of the node:
(optional) The database:
(optional) The service configuration if you've configured the node as a service:
If you don't backup the database, you can always synchronize it from scratch, but keep in mind that this process may take some time.
Don't forget to stop the node before backing up the database. Otherwise you can get a corrupted database.
sudo systemctl stop gear-node