-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup.sh
40 lines (32 loc) · 1.14 KB
/
backup.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
38
39
40
#!/bin/bash
BACKUP_NAME="nucypher"
# folder where nucypher-venv stored
NU_VENV_FOLDER=~/nucypher-venv
# folder where keys stored
NU_MAIN_FOLDER=~/.local/share/nucypher/
ETH_FOLDER=~/.ethereum
CURRENT_DATE=$(TZ=UTC-3 date +"%d-%m-%Y_%H-%M-%S")
green="\e[92m"
red="\e[91m"
normal="\e[39m"
check_path() {
if [ -d "$1" ]; then
echo -e $green"Backup folder exists $1"
else
echo -e $red "ERROR: $1 does not exists --> exit"
exit 1
fi
}
echo "Сhecking backup directories..."
for folder in $NU_VENV_FOLDER $ETH_FOLDER $NU_MAIN_FOLDER; do
check_path $folder
done
echo -e $normal"Parse external node IP"
NODE_IP=$(curl -s api.ipify.org)
echo -e $normal"Getting current Nucypher version"
NU_VERSION=$(source $NU_VENV_FOLDER/bin/activate && nucypher --version | grep version | sed -r 's/^version //')
echo -e $green "NODE_IP: $NODE_IP\n Nucypher version: $NU_VERSION"
echo -e $normal"Creating tar.gz archive"
tar --exclude='*.tar.gz' --exclude='lightchaindata/*' --exclude='chaindata/*' -zcf ~/$BACKUP_NAME\_$NU_VERSION\_$NODE_IP\_$CURRENT_DATE.tar.gz \
-C ~ .local -C ~ .ethereum
echo -e $normal"$CURRENT_DATE Backup completed."