# Main Net Database Snapshots

POX officially provides database snapshots regularly for efficient node deployment. A data snapshot represents a compressed file containing the database backup of a POX network node at a specific moment. Developers have the option to download and utilize this data snapshot to expedite the node synchronization process.

## Download the Data Snapshot

### Fullnode data snapshot

The following table displays the download address of Fullnode data snapshots for POX. Choose an appropriate data snapshot based on your location, node database type, and whether you require access to historical internal transactions.

| Fullnode Data Source                           | Download site                        | Description                                                                                                                                                                                                                                                                               |
| ---------------------------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Official data source (North America: Virginia) | <http://3.219.199.168/>              | LevelDB, , exclude internal transactions (About 1250G on May 8, 2023)                                                                                                                                                                                                                     |
| Official data source (Singapore)               | <http://52.77.31.45/>                | LevelDB, exclude internal transactions (About 1248G on May 8, 2023)                                                                                                                                                                                                                       |
| Official data source (Singapore)               | <http://52.77.31.45/saveInternalTx/> | LevelDB, include internal transactions (About 1423G on May 8, 2023)                                                                                                                                                                                                                       |
| Trongrid data source                           | <https://backup.trongrid.io/>        | LevelDB, include internal transactions (About 1527G on May 8, 2023). Note, if the error `checkpoint check failed, can't convert checkpoint from v2 to v1` is reported when the node starts, please add the configuration item `storage{checkpoint.version = 2}` to the configuration file |

**Note:** Combining LevelDB and RocksDB data is not permissible. Specify the database in the configuration file of the full POX node by setting db.engine to LEVELDB or ROCKSDB.

### Lite Fullnode data snapshot

The POX Public Chain has incorporated Lite Fullnode support since the release of GreatVoyage-v4.1.0. The Lite Fullnode requires only essential block data and the complete status data to operate, making it significantly more lightweight with a smaller database and quicker startup compared to the standard Fullnode. POX officially provides database snapshots specifically for the Lite Fullnode.

| Lite Fullnode Data Source                      | Download site          | Description |
| ---------------------------------------------- | ---------------------- | ----------- |
| Official data source (North America: Virginia) | <http://3.219.199.168> | LevelDB     |

**Tips:** Utilize the Lite Fullnode Tool to separate essential data from the entire dataset.

## Use the data snapshot

The steps for using data snapshots are as follows:

1. Obtain the relevant compressed backup database based on your requirements.
2. Unpack the compressed file of the backup database to the output-directory directory or the designated directory, depending on your preferences.
3. Startup the node. By default, the node reads the output-directory directory. If you wish to specify an alternative directory, include the -d directory parameter during the node startup.

## Others

### Lite Fullnode Tool

The Lite Fullnode Tool serves the purpose of partitioning the database of a Fullnode into a Snapshot dataset and a History dataset.

* `Snapshot dataset:`The essential dataset required for the swift initiation of the Lite Fullnode.
* `History dataset`: The archival dataset utilized for inquiries into historical data.

Before engaging in any operation with this tool, it's essential to halt the ongoing Fullnode process. The tool facilitates the segmentation of the entire data into two datasets based on the current latest block height (latest\_block\_number). Lite Fullnode initiated from snapshot datasets lacks support for querying historical data predating this block height. Additionally, the tool allows for the merging of historical datasets with snapshot datasets.

For more design details, please refer to: TIP-128.

#### Obtain Lite Fullnode Tool

LiteFullNodeTool.jar can be acquired through the compilation of the java-pox source code. Follow the steps outlined below:

1. Obtain java-pox source code

```
$ git clone https://github.com/poxprotocol/java-pox.git
$ git checkout -t origin/master
```

2. Compile

```
$ cd java-pox
$ ./gradlew clean build -x test
```

Upon completion of the compilation process, LiteFullNodeTool.jar will be produced in the java-pox/build/libs/ directory.

#### Use Lite Fullnode tool

**Options**

This tool offers an autonomous segmentation of Snapshot Dataset and History Dataset, along with a merging capability.

* `--operation | -o`: \[ split | merge ] Specify the operation as either splitting or merging.
* `--type | -t`: \[ snapshot | history ] is exclusively employed with the split operation to indicate the dataset type for segmentation. Snapshot denotes Snapshot Dataset, while history designates History Dataset.
* `--fn-data-path`: Fullnode database directory
* `--dataset-path`: During the split operation, the dataset directory is specified by the dataset-path. This path is utilized to store either the Snapshot Dataset or the History Dataset.

Otherwise, the dataset-path should denote the path for the History Dataset.

**Examples**

Commence a new POX node using the default configuration, and this will generate an output-directory within the current directory. The output-directory includes a sub-directory named database, serving as the database to undergo the splitting process.

* Split and get a `Snapshot Dataset`

First, stop the Fullnode and execute:

```
// just for simplify, locate the snapshot into `/tmp` directory,
$ java -jar LiteFullNodeTool.jar -o split -t snapshot --fn-data-path output-directory/database --dataset-path /tmp
```

Subsequently, a snapshot directory will emerge in /tmp. Compact this directory and transfer it to a location prepared for launching a Lite Fullnode.&#x20;

Remember to rename the directory from snapshot to database.&#x20;

(Ensure renaming the snapshot to the specified value, considering the default value of the storage.db.directory is database.)

* Split and get a `History Dataset`

In case historical data queries are required, the History dataset must be created and integrated into the Lite Fullnode.

```
// just for simplify, locate the history into `/tmp` directory,
$ java -jar LiteFullNodeTool.jar -o split -t history --fn-data-path output-directory/database --dataset-path /tmp
```

Subsequently, a history directory will be created in /tmp. Archive this directory, and transfer it to a Lite Fullnode.&#x20;

Given that the History dataset typically demands considerable storage, ensure that the disk has sufficient volume to accommodate the History dataset.

* Merge `History Dataset` and `Snapshot Dataset`

Both the History Dataset and Snapshot Dataset include an info.properties file to specify the block height from which they are segmented.

Ensure that the split\_block\_num in the History Dataset is not lower than the corresponding value in the Snapshot Dataset.

Once the History dataset is obtained, the Lite Fullnode can seamlessly merge with the History dataset, transforming into a fully functional Fullnode.

```
// just for simplify, assume `History dataset` is locate in /tmp
$ java -jar LiteFullNodeTool.jar -o merge --fn-data-path output-directory/database --dataset-path /tmp/history
```
