-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestore.sh
45 lines (32 loc) · 839 Bytes
/
restore.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
41
42
43
44
45
readarray c < conf
user=${c[3]::-1}
ssh_user=${c[0]::-1}
ssh_ip=${c[1]::-1}
ip=${c[4]::-1}
if [[ $3 == "local" ]]
then
index=0
readarray line < $2/backups.log
while [[ $index -lt ${#line[@]} ]]; do
echo [$index] ${line[$index]}
index=$(($index + 1))
done
read -p "Choose backup : " opt
echo "restoring ${line[$opt]::-1}"
tar -xzvf $2/${line[$opt]::-1}.tar.gz --directory=$2
rsync -avzP --delete $2/${line[$opt]::-1}/* $1/..
rm -rf $2/${line[$opt]::-1}
elif [[ $3 == "remote" ]]
then
ssh $ssh_user@$ssh_ip '
index=0
readarray line < '"$2/backups.log"'
while [[ $index -lt ${#line[@]} ]]; do
echo [$index] ${line[$index]}
index=$(($index + 1))
done
read -p "Choose backup : " opt
echo "restoring ${line[$opt]::-1}"
echo rsync -avzP --delete '"$2"'/${line[$opt]::-1}/* -e ssh '"$user@$ip:$1/.."'
'
fi