make snapshot script user-agnostic

This commit is contained in:
Alex Grin 2019-11-13 08:53:19 -05:00 committed by GitHub
parent c602432cc0
commit 8e0c7b4f43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,8 @@
echo "Running $0"
user=$(whoami)
echo "Starting servers"
sudo docker-compose up --detach
@ -11,7 +13,7 @@ echo "Waiting until lbrycrdd has caught up to the blockchain tip"
HEIGHT=$(curl -s https://explorer.lbry.com/api/v1/status | egrep -o 'height":([0-9])+' | egrep -o '[0-9]+')
while true; do
#set +eo pipefail
info=$(sudo docker exec ubuntu_lbrycrd_1 lbrycrd-cli -conf=/etc/lbry/lbrycrd.conf getblockchaininfo 2>/dev/null)
info=$(sudo docker exec ${user}_lbrycrd_1 lbrycrd-cli -conf=/etc/lbry/lbrycrd.conf getblockchaininfo 2>/dev/null)
ret=$?
if [ "$ret" != 0 ]; then echo "Waiting for lbrycrd to start"; sleep 5; continue; fi
WALLET_BLOCKS=$(echo '{"id":1,"method":"blockchain.block.get_server_height"}' | nc localhost 50001 | egrep -m 1 -o 'result": [0-9]+' | egrep -o '[0-9]+')
@ -32,13 +34,13 @@ sudo docker-compose down
BLOCKCHAIN_SNAPSHOT="$HOME/blockchain_snapshot_${WALLET_BLOCKS}_$(date +%F).tar.bz2"
echo "Making blockchain snapshot $BLOCKCHAIN_SNAPSHOT"
sudo tar -cjvf "$BLOCKCHAIN_SNAPSHOT" -C /var/lib/docker/volumes/ubuntu_lbrycrd/_data --group=$(whoami) --owner=$(whoami) blocks/ chainstate/ claimtrie/ indexes/
sudo tar -cjvf "$BLOCKCHAIN_SNAPSHOT" -C /var/lib/docker/volumes/${user}_lbrycrd/_data --group=$user --owner=$user blocks/ chainstate/ claimtrie/ indexes/
echo "Uploading blockchain snapshot to s3"
aws s3 cp "$BLOCKCHAIN_SNAPSHOT" s3://snapshots.lbry.com/blockchain/ --region us-east-2
WALLET_SNAPSHOT="$HOME/wallet_snapshot_${WALLET_BLOCKS}_$(date +%F).tar.bz2"
echo "Making wallet snapshot $SNAPSHOT"
sudo tar -cjvf "$WALLET_SNAPSHOT" -C /var/lib/docker/volumes/ubuntu_wallet_server/_data --group=$(whoami) --owner=$(whoami) claims.db hist/ meta/ utxo/
sudo tar -cjvf "$WALLET_SNAPSHOT" -C /var/lib/docker/volumes/${user}_wallet_server/_data --group=$user --owner=$user claims.db hist/ meta/ utxo/
echo "Uploading wallet snapshot to s3"
aws s3 cp "$WALLET_SNAPSHOT" s3://snapshots.lbry.com/wallet/ --region us-east-2