Last active
September 16, 2021 10:54
-
-
Save a1300/4ca85df387100651ca6041f8d9f14c31 to your computer and use it in GitHub Desktop.
upgrade mainnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################## | |
# backup current database | |
################## | |
sudo docker stop node1 | |
sudo docker rm node1 | |
sleep 15s | |
LAST_HEIGHT=$(sudo docker exec -it db1 psql -U postgres -d postgres -c "select max(height) from block" | sed -n 3p | sed 's/ //g;s/\t//g;s/\r//g;s/$//g') | |
echo "$LAST_HEIGHT" | |
BACKUP_DATE=$(date +%d-%m-%Y"_"%H_%M_%S) | |
# backup | |
sudo docker exec -t db1 pg_dumpall -c -U postgres > v2_height_${LAST_HEIGHT}_v1.0.80.sql | |
zip v2_height_${LAST_HEIGHT}_v1.0.80.zip v2_height_${LAST_HEIGHT}_v1.0.80.sql | |
##################### | |
# restore | |
##################### | |
sudo apt-get install zip unzip | |
wget https://mainnet.snapshots.gny.io/v2_height_1831668_16-09-2021_09_29_39.zip | |
unzip v2_height_1831668_16-09-2021_09_29_39.zip | |
sudo docker-compose --file docker-compose.yml down | |
sudo docker volume prune --force | |
sudo docker-compose --file docker-compose.yml pull | |
sudo docker-compose --file docker-compose.yml up --no-start | |
sudo docker-compose --file docker-compose.yml start db1 | |
sleep 10s | |
cat v2_height_1831668_16-09-2021_09_29_39.sql | sudo docker exec -i db1 psql -U postgres | |
sudo docker-compose --file docker-compose.yml up --detach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment