-
Notifications
You must be signed in to change notification settings - Fork 0
/
restore_checkpoint.sh
executable file
·37 lines (32 loc) · 1.21 KB
/
restore_checkpoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
[[ -z "${POCKETDIR}" ]] && POCKETDIR="$HOME/.pocketcoin" || POCKETDIR="${POCKETDIR}"
CHECKPOINT_FILE="latest.tgz"
if [ -f "$POCKETDIR/$CHECKPOINT_FILE" ]
then
read -p "Checkpoint file $POCKETDIR/$CHECKPOINT_FILE already exists, overwrite it? (y/n) " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Re-downloading checkpoint file..."
rm "$POCKETDIR/$CHECKPOINT_FILE"
wget --directory-prefix="$POCKETDIR" "https://snapshot.pocketnet.app/$CHECKPOINT_FILE"
else
exit
fi
else
echo "Downloading checkpoint file..."
wget --directory-prefix="$POCKETDIR" "https://snapshot.pocketnet.app/$CHECKPOINT_FILE"
fi
if [ -f "$POCKETDIR/$CHECKPOINT_FILE" ]
then
echo "Deleting existing blockchain data directories..."
rm -r $POCKETDIR/blocks
rm -r $POCKETDIR/chainstate
rm -r $POCKETDIR/indexes
rm -r $POCKETDIR/pocketdb
rm -r $POCKETDIR/checkpoints
echo "Restoring blockchain data from checkpoint..."
tar -xzvf $POCKETDIR/$CHECKPOINT_FILE -C $POCKETDIR
echo "Blockchain data restored from checkpoint. Start pocketnetd (probably in sync mode)."
else
echo "Something went wrong, could not find the checkpoint file after trying to download it."
fi