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
│ ├── indexstore
│ └── sharky
├── password
├── stamperstore
│ └── ...
└── statestore
│ └── ...
Data Directory Locations
The default data directory for your Bee node will depend on the installation method used.
If Bee is installed to run as a service using a package manager such as apt or yum, then it can be started using your system's services manager such as systemctl using a command like systemctl start bee. However, after installing with a package manager, Bee can also by started using the bee start command used for running Bee with a shell script / binary install. When the bee start command is run, it will create a SECOND data directory alongside the default data directory for your package manager at the same directory it would for the shell script installation:
/home/<user>/.bee
In that case, you would have two separate data directories in two different locations, and the directory used will depend on whether you start your node using a service manager like systemctl or the bee start command.
If you installed Bee via a package manager but sometimes start it manually, you may have two separate data directories:
- System service (
systemctl start bee) → Uses/var/lib/bee. - Manual start (
bee start) → Uses/home/<user>/.bee.
The exact directory will differ depending on your system. See Configuration page.
apt and yum / rpm Package Managers
Default data-dir location:
/var/lib/bee
Homebrew (amd64)
Default data-dir location:
/usr/local/var/lib/swarm-bee