Backups
Backing up your Bee node involves copying and saving files from the data directory specified in the dat-dir configuration option, along with the node's password. The details of where and how this option is specified will vary depending on the type of configuration method used (YAML file, command line flag, or environment variable).
A node's password may be specified in several different locations. It can be specified either through the password option or the password-file option. For a backup, you will need to either copy the password option value, or copy the file itself from the location specified by the password-file option.
Don't forget - it's not a backup until you're sure the backup files work! Make sure to test restoring from backup files and password to prevent loss of assets due to data loss or corruption.
Bee Files
A full Bee node backup includes the keys, localstore, stamperstore, statestore, and password files. The node should be stopped before taking a backup and not restarted until restoring the node from the backup to prevent the node from getting out of sync with the network.
Key data from the keys directory allows access to Bee node's Gnosis account (provided that you have also made sure to back the password for your keys). If your keys and password are lost or stolen it could lead to the loss of all assets in that account. The stamperstore contains postage stamp data. If lost, previously purchased postage stamps will become unusable.
Statestore and Localstore.
The statestore retains data related to its operation, and the localstore contains chunks locally which are frequently requested, pinned in the node, or are in the node's neighborhood of responsibility.
As the data in statestore and localstore continually changes during normal operation of a node, when taking a backup the node should first be stopped and not re-connected to the Swarm network until restoring from the backup (otherwise the statestore and localstore files will get out of sync with the network). It is possible to restore using out of sync statestore and localstore files, however it may lead to data loss or unexpected behavior related to chunk uploads, postage stamps, and more.
Stamperstore
The stamperstore contains postage stamp batch related data, and so is important to include in your backup if you have purchased any postage batches which you wish to continue using.
Keys
The keys directory contains the following key files:
libp2p.keylibp2p_v2.keypss.keyswarm.key
These keys are generated during the Bee node's initialisation and are required for maintaining access to your node.
The swarm.key file grants full control over your node's Gnosis Chain account. If lost, you cannot recover funds. If stolen, your assets can be drained.
To use swarm.key to manage the Gnosis account for a node through Metamask or other wallets, exportSwarmKeys can be used to convert swarm.key to a compatible format.
Data Directory Structure
The data directory contains four directories. Its default location depends on the node install method and startup method used.
├── kademlia-metrics
│ └── ...
├── keys
│ ├── libp2p.key
│ ├── libp2p_v2.key
│ ├── pss.key
│ └── swarm.key
├── localstore