Recover database from snapshot

Prerequisites

  1. go 1.21

  2. postgresql 16( version below 16 may cause some incompatible issue )

// install postgresql 16 
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
$ sudo apt update
$ sudo apt install postgresql-16 postgresql-client-16 -y
// check if postgresql 16 installed properly
$ psql --version
  1. Download snapshot files ( try download tools like axel if it takes too long to download )

wget https://zkfair-blockchain-snapshot.s3.ap-east-1.amazonaws.com/prover_db_08_26_2024.sql.tar.gz
wget https://zkfair-blockchain-snapshot.s3.ap-east-1.amazonaws.com/state_db_08_26_2024.sql.tar.gz

Restore

  1. Clone repository

repository:https://github.com/ZKFair/zkfair-cdk-validium-node.gitbranch:develop

git clone https://github.com/ZKFair/zkfair-cdk-validium-node.git
cd zkfair-cdk-validium-node
// go version 1.21 is recommended
go build -o ./build/cmd ./cmd
  1. Modify restore configuration, change the highlighted part to your own database connection configuration

vi snapshot_restore.toml

snapshot_restore.toml:

You must fill in the following part with your own information.
- [StateDB] # Your own StateDB connection
- [HashDB] # Your own HashDB(ProverDB) connection
[Log]
Environment = "development" # "production" or "development"
Level = "debug" # "info"
Outputs = ["stderr"]

[StateDB] # Your own StateDB connection
User = "state_user"
Password = "state_password"
Name = "state_db"
Host = "127.0.0.1"
Port = "5432"
EnableLog = false
MaxConns = 200

[HashDB] # Your own HashDB(ProverDB) connection
User = "prover_user"
Password = "prover_password"
Name = "prover_db"
Host = "127.0.0.1"
Port = "5433"
EnableLog = false
MaxConns = 200
  1. Restore from snapshot

./build/cmd restore --cfg ./snapshot_restore.toml -is ./state_db_08_26_2024.sql.tar.gz -ih ./prover_db_08_26_2024.sql.tar.gz

Last updated