# Instructions for Polygon Erigon Snapshot

The instructions below will fully restore Erigon's data directory by downloading each file and subdirectories individually. Use aria2 or wget to download all of the Erigon files. Last, modify the ownership of the files so Erigon can access them.

<details>

<summary>Tools to use</summary>

wget, which is ultimate command line downloader. However, wget failed to accelerate download speed.

For ultra fast downloading use aria2. It is a utility for downloading files. aria2 supported HTTP(S) protocols. It tries to utilize maximum download bandwidth.

Please download the file that will tell aria2c which files to download and which directory to save them to. Then, use aria2c to download all of the Erigon files.

</details>

1. Stop the erigon services

```sh
service erigon stop 
//OR 
systemctl stop erigon.service
```

2. Navigate to the directory with your erigon data store in it, then download the compress file.

```bash
cd /var/lib/erigon/
```

3. Take a backup of existing erigon data

```bash
cp -frvp /var/lib/erigon/data
```

4. Remove data directory from /var/lib/erigon/

```bash
rm -r ./data
```

5. Open tmux or use screen/nohup to keep downloading after you close your connection.
6. Download the files using aria2c. This will download up to 12 files at a time (-j 12) and will use up to 12 connections to the server (-x 12).

```bash
TIMESTAMP=$(date +"%Y-%m-%d"); aria2c -j 22 -x 16 -s 32 -c https://snapshots.girnaartech.com/polygon/amoy-testnet/erigon/${TIMESTAMP}-erigon-amoy-testnet/erigon.tar.zst
```

7. Decompress the file using zstd utility

```bash
zstd -d erigon.tar.zst -c | tar -xvf -
```

OR you can use wget.

Create a timestamp with the current date and Download the files using wget:

```bash
TIMESTAMP=$(date +"%Y-%m-%d"); wget -q --show-progress -m -r -nH --cut-dirs=4 --no-parent --reject="index.html*" https://snapshots.girnaartech.com/polygon/amoy-testnet/erigon/${TIMESTAMP}-erigon-amoy-testnet/erigon.tar.zst
```

This will download files with current user ownership. Change all files to be owned by erigon and the erigon group.

```bash
sudo chown -R erigon:erigon /var/lib/erigon
```

8. That's it! Start Erigon and check the logs.


---

# 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://snapshotdocs.girnaartech.com/instructions-for-polygon-erigon-snapshot.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.
