# Node Databases

### **Databases**[​](https://docs.multiversx.com/validators/node-databases#node-databases) <a href="#node-databases" id="node-databases"></a>

Nodes use simple Key-Value type databases.

Nodes use Serial LevelDB databases to persist processed blocks, transactions, and so on.

Data retention can be controlled in `config.toml` using pruning flags. There are two flags for the latest versions:

* `ValidatorCleanOldEpochsData`
* `ObserverCleanOldEpochsData`

For older configurations, the single flag is:

* `CleanOldEpochsData`

Setting these flags to false prevents the deletion of old databases.

By default, validators only keep the last 4 epochs and delete older ones for freeing disk space.

The default databases directory is `<node-working-directory>/db` and it's content should match the following structure:

```
/db
└── <chain id>
    ├── Epoch_X
    │  └── Shard_X -------->
    │        ├── BlockHeaders
    │        │    ├── 000001.log
    │        │    ├── CURRENT
    │        │    ├── LOCK
    │        │    ├── LOG
    │        │    └── MANIFEST-000000
    │        ├── BootstrapData
    │        │    ├── 000001.log
    |     .............
    └── Static
        └── Shard_X -------->
            ├── AccountsTrie
            │     └── MainDB
            │           ├── 000001.log
         .............
```

During startup, nodes check for an existing database and sync any missing data from the network to match the current network height.

### Starting a Node with Existing Databases

When both the configuration and the database shard match, the node inherits the full database state and needs to sync only the remaining items. For example, if a node starts with a database at epoch 255 and the current epoch is 256, it will sync only the missing epoch data.

The configuration of the new node should mirror that of the predecessor, with the exception of the BLS key, which does not depend on the database.

To expedite synchronization, it's possible to copy the fully synced database from another node. This process involves transferring the entire `db/` directory from the source to the target node.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onefinity.network/technology/run-a-onefinity-node/nodes/node-databases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
