-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaula04.sh
67 lines (55 loc) · 1.12 KB
/
aula04.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
date=$(date +%d%m%Y-%H%M%S)
PASTAS_BACKUP="/root/pastasbackup"
LOCAL_BACKUP="/root/backups/"
LOCAL_RESTORE="/root/restore/"
NOME_ARQUIVO="backup-$date.tar.gz"
PATH_BACKUP=$LOCAL_BACKUP$NOME_ARQUIVO
MONITOR_FILE="/root/monitor"
if [ ! -d $LOCAL_BACKUP ]
then
mkdir $LOCAL_BACKUP
fi
if [ ! -d $LOCAL_RESTORE ]
then
mkdir $LOCAL_RESTORE
fi
completo()
{
if tar -czvf $PATH_BACKUP -T $PASTAS_BACKUP
then
echo "OK" | tee $MONITOR_FILE
else
echo "ERRO" | tee $MONITOR_FILE
exit 1
fi
}
menu_recuperar()
{
clear
backup=$(ls $LOCAL_BACKUP)
echo -e "----------------------"
echo -e "Backup disponível: \n $backup \n\n"
echo -e "----------------------"
echo -e "Confirma? [s|N]"
read confirma
case $confirma in
s|S) recuperar $LOCAL_BACKUP$backup $LOCAL_RESTORE ;;
*) exit 0 ;;
esac
}
recuperar()
{
backup_recupera=$1
destino=$2
if ! tar -xvzf $backup_recupera -C $destino >>1/dev/null
then
exit 1
fi
}
case $1 in
completo) completo ;;
recuperacao) menu_recuperar ;;
recuperar) recuperar $2 $3 ;;
*) echo "ERROOOOUUUUU" ;;
esac